Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

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

MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

It's supposed to do this http://screencast.com/t/c5vk81kZY
what error do you get when you run the program ?
That's the error: "Run-Time Check Failure #3 - The variable 'c' is being used without being initialised."

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

cant you write c = b-40*(a*1.5)+40; instead of const double c = b-40*(a*1.5)+40;
I tried it in visual studio, it gives errors again
besides it seems the { is misplaced for first if { <-----not here if (kids > 2 && b > 40) <<
hmm sec
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 ----------------------"
ok lemme edit this in my compiler ...I will post it after it gets working
Thank you so much
#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; }
well just add the prototype for system function in header and my code below seems to work #include #include 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; }
did that help ?
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..!!
@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
It works for me in turbo c++
Hmm is this a windows application?? Do you have visual studio ??
Make sure you change the header accordingly for my program , note I changed the header because I am using turbo c++
I also removed using namespace std part
turbo C++ works without namespace std?
lols It works either way ..was just trying to make the code work for you
..... :D
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?
That comes under logical error ...Iets deal with syntax error first
Yea the syntax error is fixed
wow great !! good work :)
Could you help me out with the logical error? :S
It appears that its something small, yet so hard to see
ok wait ..though its midnight here I dunno if my brain is ready to look at logical errors
Is this urgent ?
I got a test tomorrow in C++ at my college so I will be studying all night apparently
Unlucky me :S
Oh I see ..what time is it there now ?
9:40 pm
here 12:17 am :)
I see bro, if you are too sleepy then its ok np
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
=) thx bro
yw :)
Ok done ! :) #include #include 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; }
Hope that works !
for 100 hours of 2$ per hour and 1 kid it gives me 94$ per week as a result like mine :S
is that right or wrong ?
its wrong by far :S
I am using calculator to test the results
ok try other inputs ...meanwhile I will try editing :)
oh got it :)
Kindly Tell Me The Error Name....!! I Am Using Code::Blocks..!!
I solved it guys, here: #include #include 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; }
The tricky line was this c = (b-40)*(1.5*a)+40*a;
notice the location of "a"
oops yaa !! I made a silly mistake there ! probably because I am almost abt to be asleep
I Am Concerned About The Errors, Not The Complete Solution Of The Program...!!
We fixed the syntax error red price, it was because of the braces
So is your program iver @Christos ? :)
*over
Yea :D pheu its over
Yes, And I Mentioned It Earlier...!! Anyways, Best Of Luck For Your Exam...!! I have Also A Exam Of C++ Today....!!
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
Thanks....!! Of-Course, As For Me These Are The Fundamental Concepts Of C/C++/Java
Nice red I'm gonna do java as well
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...!!
@christos nw dat was funny..
How!
@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.. !! :/

Not the answer you are looking for?

Search for more explanations.

Ask your own question