Quantcast

A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Christos

  • one year ago

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

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

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

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

    what error do you get when you run the program ?

  3. Christos
    • one year ago
    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."

  4. AravindG
    • one year ago
    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;

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

    I tried it in visual studio, it gives errors again

  6. AravindG
    • one year ago
    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; }

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

    hmm sec

  8. Christos
    • one year ago
    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 ----------------------"

  9. AravindG
    • one year ago
    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

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

    Thank you so much

  11. RedPrince
    • one year ago
    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; }

  12. AravindG
    • one year ago
    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; }

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

    did that help ?

  14. RedPrince
    • one year ago
    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..!!

  15. Christos
    • one year ago
    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

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

    It works for me in turbo c++

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

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

  18. AravindG
    • one year ago
    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++

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

    I also removed using namespace std part

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

    turbo C++ works without namespace std?

  21. AravindG
    • one year ago
    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

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

    ..... :D

  23. Christos
    • one year ago
    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?

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

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

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

    Yea the syntax error is fixed

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

    wow great !! good work :)

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

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

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

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

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

    @AravindG

  30. AravindG
    • one year ago
    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

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

    Is this urgent ?

  32. Christos
    • one year ago
    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

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

    Unlucky me :S

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

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

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

    9:40 pm

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

    here 12:17 am :)

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

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

  38. AravindG
    • one year ago
    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

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

    =) thx bro

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

    yw :)

  41. AravindG
    • one year ago
    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; }

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

    Hope that works !

  43. Christos
    • one year ago
    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

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

    is that right or wrong ?

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

    its wrong by far :S

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

    I am using calculator to test the results

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

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

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

    oh got it :)

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

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

  50. Christos
    • one year ago
    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; }

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

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

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

    notice the location of "a"

  53. AravindG
    • one year ago
    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

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

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

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

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

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

    So is your program iver @Christos ? :)

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

    *over

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

    Yea :D pheu its over

  59. RedPrince
    • one year ago
    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....!!

  60. AravindG
    • one year ago
    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

  61. RedPrince
    • one year ago
    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

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

    Nice red I'm gonna do java as well

  63. RedPrince
    • one year ago
    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...!!

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

    @christos nw dat was funny..

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

    How!

  66. Shijin
    • one year ago
    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.. !! :/

  67. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy

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.