Got Homework?
Connect with other students for help. It's a free community.
Here's the question you clicked on:
 0 viewing
C++
Please tell me where am I wrong in this program! :(
http://pastebin.com/iauPm4q9
 one year ago
 one year ago
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

ChristosBest ResponseYou've already chosen the best response.0
It's supposed to do this http://screencast.com/t/c5vk81kZY
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
what error do you get when you run the program ?
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
That's the error: "RunTime Check Failure #3  The variable 'c' is being used without being initialised."
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
cant you write c = b40*(a*1.5)+40; instead of const double c = b40*(a*1.5)+40;
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
I tried it in visual studio, it gives errors again
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
besides it seems the { is misplaced for first if { <not here if (kids > 2 && b > 40) <<<here const double c = b40*(a*1.5)+40; cout << "His weekly salaty is: " << c(c*6/100)+(c*14/100)1035; }
 one year ago

ChristosBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.1
ok lemme edit this in my compiler ...I will post it after it gets working
 one year ago

RedPrinceBest ResponseYou've already chosen the best response.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 = b40*(a*1.5)+40; cout << "His weekly salaty is: " << (c(c*6/100)+(c*14/100)1035); } if (kids <= 2 && b > 40) { const double c = b40*(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

AravindGBest ResponseYou've already chosen the best response.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 = b40*(a*1.5)+40; cout << "His weekly salaty is: " << c(c*6/100)+(c*14/100)1035; } if (kids <= 2 && b > 40) { const double c = b40*(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

RedPrinceBest ResponseYou've already chosen the best response.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

ChristosBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.1
It works for me in turbo c++
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
Hmm is this a windows application?? Do you have visual studio ??
 one year ago

AravindGBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.1
I also removed using namespace std part
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
turbo C++ works without namespace std?
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
lols It works either way ..was just trying to make the code work for you
 one year ago

ChristosBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.1
That comes under logical error ...Iets deal with syntax error first
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
Yea the syntax error is fixed
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
wow great !! good work :)
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
Could you help me out with the logical error? :S
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
It appears that its something small, yet so hard to see
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
ok wait ..though its midnight here I dunno if my brain is ready to look at logical errors
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
I got a test tomorrow in C++ at my college so I will be studying all night apparently
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
Oh I see ..what time is it there now ?
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
I see bro, if you are too sleepy then its ok np
 one year ago

AravindGBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.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*(b40)) ; cout << "His weekly salaty is: " << (c(c*(6/100))+(c*(14/100))1035); } if (kids <= 2 && b > 40) { c = c+(1.5*a*(b40)) ; 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

ChristosBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.1
is that right or wrong ?
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
I am using calculator to test the results
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
ok try other inputs ...meanwhile I will try editing :)
 one year ago

RedPrinceBest ResponseYou've already chosen the best response.0
Kindly Tell Me The Error Name....!! I Am Using Code::Blocks..!!
 one year ago

ChristosBest ResponseYou've already chosen the best response.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 = (b40)*(a*1.5)+40*a; cout << "His weekly salaty is: " << c(c*6/100)(c*14/100)1035; } if (kids <= 2 && b > 40) { const double c = (b40)*(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

ChristosBest ResponseYou've already chosen the best response.0
The tricky line was this c = (b40)*(1.5*a)+40*a;
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
notice the location of "a"
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
oops yaa !! I made a silly mistake there ! probably because I am almost abt to be asleep
 one year ago

RedPrinceBest ResponseYou've already chosen the best response.0
I Am Concerned About The Errors, Not The Complete Solution Of The Program...!!
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
We fixed the syntax error red price, it was because of the braces
 one year ago

AravindGBest ResponseYou've already chosen the best response.1
So is your program iver @Christos ? :)
 one year ago

RedPrinceBest ResponseYou've already chosen the best response.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

AravindGBest ResponseYou've already chosen the best response.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

RedPrinceBest ResponseYou've already chosen the best response.0
Thanks....!! OfCourse, As For Me These Are The Fundamental Concepts Of C/C++/Java
 one year ago

ChristosBest ResponseYou've already chosen the best response.0
Nice red I'm gonna do java as well
 one year ago

RedPrinceBest ResponseYou've already chosen the best response.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

ShijinBest ResponseYou've already chosen the best response.0
@christos nw dat was funny..
 10 months ago

ShijinBest ResponseYou've already chosen the best response.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
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
 Engagement 19 Mad Hatter
 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.