Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Christos

C++ Please tell me where am I wrong in this program! :( http://pastebin.com/iauPm4q9

  • one year ago
  • one year ago

  • This Question is Closed
  1. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    It's supposed to do this http://screencast.com/t/c5vk81kZY

    • one year ago
  2. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    what error do you get when you run the program ?

    • one year ago
  3. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    That's the error: "Run-Time Check Failure #3 - The variable 'c' is being used without being initialised."

    • one year ago
  4. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    cant you write c = b-40*(a*1.5)+40; instead of const double c = b-40*(a*1.5)+40;

    • one year ago
  5. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    I tried it in visual studio, it gives errors again

    • one year ago
  6. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    besides it seems the { is misplaced for first if { <-----not here if (kids > 2 && b > 40) <<<here const double c = b-40*(a*1.5)+40; cout << "His weekly salaty is: " << c-(c*6/100)+(c*14/100)-10-35; }

    • one year ago
  7. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    hmm sec

    • one year ago
  8. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Now it gives me this "Project : error (null) : Edit and Continue could not create a safe command line to compile changes. UNC, relative and remote drive paths are disallowed. --------------------- Done ----------------------"

    • one year ago
  9. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    ok lemme edit this in my compiler ...I will post it after it gets working

    • one year ago
  10. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you so much

    • one year ago
  11. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    #include "iostream" using namespace std; int main() { double a, b, kids; cout << "Enter an employee's salary per hour "; cin >> a; cout << "Enter the number of hours he worked in the current week "; cin >> b; cout << "How many kids does he have: "; cin >> kids; if (kids > 2 && b > 40) { const double c = b-40*(a*1.5)+40; cout << "His weekly salaty is: " << (c-(c*6/100)+(c*14/100)-10-35); } if (kids <= 2 && b > 40) { const double c = b-40*(a*1.5)+40; cout << "His weekly salaty is: " << c-(c*6/100)+(c*14/100)-10; } if (kids <= 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)+(d*14/100)-10; } if (kids > 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)+(d*14/100)-10; } system("pause"); return 0; }

    • one year ago
  12. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    well just add the prototype for system function in header and my code below seems to work #include <stdafx.h> #include <iostream.h> int main() { double a, b, d, kids; cout << "Enter an employee's salary per hour "; cin >> a; cout << "Enter the number of hours he worked in the current week "; cin >> b; cout << "How many kids does he have: "; cin >> kids; if (kids > 2 && b > 40) { const double c = b-40*(a*1.5)+40; cout << "His weekly salaty is: " << c-(c*6/100)+(c*14/100)-10-35; } if (kids <= 2 && b > 40) { const double c = b-40*(a*1.5)+40; cout << "His weekly salaty is: " << c-(c*6/100)+(c*14/100)-10; } if (kids <= 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)+(d*14/100)-10; } if (kids > 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)+(d*14/100)-10; } system("pause"); return 0; }

    • one year ago
  13. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    did that help ?

    • one year ago
  14. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    Actually., You Are Not Using The Braces Correctly...!! When You Are Not Using Braces, Then Only One Statement After The if Will Be Associated With That if...!! Then, Conditions After That Statement (One Statement) Will Not Be In The Scope Of if Statement..!!

    • one year ago
  15. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    @AravindG with your script I get this "Project : error (null) : Edit and Continue could not create a safe command line to compile changes. UNC, relative and remote drive paths are disallowed. --------------------- Done ----------------------" @RedPrince with your script I get a run time error

    • one year ago
  16. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    It works for me in turbo c++

    • one year ago
  17. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Hmm is this a windows application?? Do you have visual studio ??

    • one year ago
  18. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    Make sure you change the header accordingly for my program , note I changed the header because I am using turbo c++

    • one year ago
  19. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    I also removed using namespace std part

    • one year ago
  20. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    turbo C++ works without namespace std?

    • one year ago
  21. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    lols It works either way ..was just trying to make the code work for you

    • one year ago
  22. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    ..... :D

    • one year ago
  23. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    It appears that the code doesn't correspond to this http://screencast.com/t/k3yQmLgQ3UN ? Is there something that must be modified, or am I just silly?

    • one year ago
  24. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    That comes under logical error ...Iets deal with syntax error first

    • one year ago
  25. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Yea the syntax error is fixed

    • one year ago
  26. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    wow great !! good work :)

    • one year ago
  27. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Could you help me out with the logical error? :S

    • one year ago
  28. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    It appears that its something small, yet so hard to see

    • one year ago
  29. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    @AravindG

    • one year ago
  30. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    ok wait ..though its midnight here I dunno if my brain is ready to look at logical errors

    • one year ago
  31. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    Is this urgent ?

    • one year ago
  32. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    I got a test tomorrow in C++ at my college so I will be studying all night apparently

    • one year ago
  33. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Unlucky me :S

    • one year ago
  34. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    Oh I see ..what time is it there now ?

    • one year ago
  35. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    9:40 pm

    • one year ago
  36. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    here 12:17 am :)

    • one year ago
  37. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    I see bro, if you are too sleepy then its ok np

    • one year ago
  38. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    nvm .. I can understand the pressure you will be feeling before the test ,I experienced the same 1 month before :) ..I will sort this out

    • one year ago
  39. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    =) thx bro

    • one year ago
  40. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    yw :)

    • one year ago
  41. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    Ok done ! :) #include <stdafx.h> #include <iostream.h> int main() { double a, b,c, kids; cout << "Enter an employee's salary per hour "; cin >> a; cout << "Enter the number of hours he worked in the current week "; cin >> b; cout << "How many kids does he have: "; cin >> kids; c = a*b; if (kids > 2 && b > 40) { c = c+(1.5*a*(b-40)) ; cout << "His weekly salaty is: " << (c-(c*(6/100))+(c*(14/100))-10-35); } if (kids <= 2 && b > 40) { c = c+(1.5*a*(b-40)) ; cout << "His weekly salaty is: " << c-(c*(6/100))+(c*(14/100))-10; } if (kids <= 2 && b <= 40) { cout << "His weekly salaty is: " << c-(c*(6/100))+(d*(14/100))-10; } if (kids > 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)+(d*14/100)-10; } system("pause"); return 0; }

    • one year ago
  42. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    Hope that works !

    • one year ago
  43. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    for 100 hours of 2$ per hour and 1 kid it gives me 94$ per week as a result like mine :S

    • one year ago
  44. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    is that right or wrong ?

    • one year ago
  45. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    its wrong by far :S

    • one year ago
  46. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    I am using calculator to test the results

    • one year ago
  47. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    ok try other inputs ...meanwhile I will try editing :)

    • one year ago
  48. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    oh got it :)

    • one year ago
  49. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    Kindly Tell Me The Error Name....!! I Am Using Code::Blocks..!!

    • one year ago
  50. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    I solved it guys, here: #include <stdafx.h> #include <iostream> using namespace std; int main() { double a, b, d, kids; cout << "Enter an employee's salary per hour "; cin >> a; cout << "Enter the number of hours he worked in the current week "; cin >> b; cout << "How many kids does he have: "; cin >> kids; if (kids > 2 && b > 40) { const double c = (b-40)*(a*1.5)+40*a; cout << "His weekly salaty is: " << c-(c*6/100)-(c*14/100)-10-35; } if (kids <= 2 && b > 40) { const double c = (b-40)*(1.5*a)+40*a; cout << "His weekly salaty is: " << c-(c*6/100)-(c*14/100)-10; } if (kids <= 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)-(d*14/100)-10; } if (kids > 2 && b <= 40) { const double d = a*b; cout << "His weekly salaty is: " << d-(d*6/100)-(d*14/100)-10; } system("pause"); return 0; }

    • one year ago
  51. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    The tricky line was this c = (b-40)*(1.5*a)+40*a;

    • one year ago
  52. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    notice the location of "a"

    • one year ago
  53. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    oops yaa !! I made a silly mistake there ! probably because I am almost abt to be asleep

    • one year ago
  54. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    I Am Concerned About The Errors, Not The Complete Solution Of The Program...!!

    • one year ago
  55. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    We fixed the syntax error red price, it was because of the braces

    • one year ago
  56. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    So is your program iver @Christos ? :)

    • one year ago
  57. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    *over

    • one year ago
  58. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Yea :D pheu its over

    • one year ago
  59. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    Yes, And I Mentioned It Earlier...!! Anyways, Best Of Luck For Your Exam...!! I have Also A Exam Of C++ Today....!!

    • one year ago
  60. AravindG
    Best Response
    You've already chosen the best response.
    Medals 1

    glad to hear that :) ..Well then I am off ..All the best for your exam :) make sure you put the braces correctly in the program

    • one year ago
  61. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    Thanks....!! Of-Course, As For Me These Are The Fundamental Concepts Of C/C++/Java

    • one year ago
  62. Christos
    Best Response
    You've already chosen the best response.
    Medals 0

    Nice red I'm gonna do java as well

    • one year ago
  63. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    Many Concepts Are Same In Java...! If You Know About C/C++ Then Java Is Not Much Difficult For You...!! I Am Also Interested In Java...!!

    • one year ago
  64. Shijin
    Best Response
    You've already chosen the best response.
    Medals 0

    @christos nw dat was funny..

    • 10 months ago
  65. RedPrince
    Best Response
    You've already chosen the best response.
    Medals 0

    How!

    • 10 months ago
  66. Shijin
    Best Response
    You've already chosen the best response.
    Medals 0

    @redprince all of u were wresling so much with d code, u were changin d headers, tryin braces and in d end , all der was is a change in equation... i cant stand not laughin wen i guess i to will be in dis position one time.. !! :/

    • 10 months ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.