A community for students.
Here's the question you clicked on:
 0 viewing
Christos
 3 years ago
C++
Please tell me where am I wrong in this program! :(
http://pastebin.com/iauPm4q9
Christos
 3 years ago
C++ Please tell me where am I wrong in this program! :( http://pastebin.com/iauPm4q9

This Question is Closed

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0It's supposed to do this http://screencast.com/t/c5vk81kZY

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1what error do you get when you run the program ?

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

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

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0I tried it in visual studio, it gives errors again

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1besides 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; }

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0Now 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 "

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1ok lemme edit this in my compiler ...I will post it after it gets working

RedPrince
 3 years ago
Best 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; }

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1well 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; }

RedPrince
 3 years ago
Best ResponseYou've already chosen the best response.0Actually., 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..!!

Christos
 3 years ago
Best 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

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1It works for me in turbo c++

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0Hmm is this a windows application?? Do you have visual studio ??

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1Make sure you change the header accordingly for my program , note I changed the header because I am using turbo c++

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1I also removed using namespace std part

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0turbo C++ works without namespace std?

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1lols It works either way ..was just trying to make the code work for you

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0It 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?

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1That comes under logical error ...Iets deal with syntax error first

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0Yea the syntax error is fixed

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1wow great !! good work :)

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0Could you help me out with the logical error? :S

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0It appears that its something small, yet so hard to see

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

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

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1Oh I see ..what time is it there now ?

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0I see bro, if you are too sleepy then its ok np

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1nvm .. I can understand the pressure you will be feeling before the test ,I experienced the same 1 month before :) ..I will sort this out

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1Ok 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; }

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0for 100 hours of 2$ per hour and 1 kid it gives me 94$ per week as a result like mine :S

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1is that right or wrong ?

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0I am using calculator to test the results

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1ok try other inputs ...meanwhile I will try editing :)

RedPrince
 3 years ago
Best ResponseYou've already chosen the best response.0Kindly Tell Me The Error Name....!! I Am Using Code::Blocks..!!

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0I 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; }

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0The tricky line was this c = (b40)*(1.5*a)+40*a;

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0notice the location of "a"

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

RedPrince
 3 years ago
Best ResponseYou've already chosen the best response.0I Am Concerned About The Errors, Not The Complete Solution Of The Program...!!

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0We fixed the syntax error red price, it was because of the braces

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1So is your program iver @Christos ? :)

RedPrince
 3 years ago
Best ResponseYou've already chosen the best response.0Yes, And I Mentioned It Earlier...!! Anyways, Best Of Luck For Your Exam...!! I have Also A Exam Of C++ Today....!!

AravindG
 3 years ago
Best ResponseYou've already chosen the best response.1glad to hear that :) ..Well then I am off ..All the best for your exam :) make sure you put the braces correctly in the program

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

Christos
 3 years ago
Best ResponseYou've already chosen the best response.0Nice red I'm gonna do java as well

RedPrince
 3 years ago
Best ResponseYou've already chosen the best response.0Many 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...!!

anonymous
 2 years ago
Best ResponseYou've already chosen the best response.0@christos nw dat was funny..

anonymous
 2 years ago
Best 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.. !! :/
Ask your own question
Sign UpFind 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
 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.