Urgent Porgramming help needed

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 1
Reputation: skwalker112 is an unknown quantity at this point 
Solved Threads: 0
skwalker112 skwalker112 is offline Offline
Newbie Poster

Urgent Porgramming help needed

 
1
  #1
Sep 22nd, 2006
I have to write this program by 12 a.m. tonight and i need help writing this program below. I will work with whoever can give me help all night if that is what it takes


I'm trying to write a small code that will ask the user to choose between Orange county or Seminole county sales tax calculation.
- The user will also have the option to quit the program. (You can use 1, 2, and 3 respectively).
- If the incorrect choice is typed, display an error message and prompt the user to re-enter a choice.
- If the user selects one of the two counties, the program should prompt the user to enter the price of the item.
- The program must then calculate the sales tax according to the following:
- Orange county tax is 6.5%.
- Seminole county tax is 7.0%.
- Finally, the program must output the price, tax, and total amount.
- The process must continue until the user enters the option to quit the program.


Here is a bit of my code but i don't know what to do next:
am i off to the right start or what?
CODE:



  1. using namespace std;
  2. int main()
  3. {
  4. bool done;
  5. int num1;
  6. int num2;
  7. int userChoice;
  8. bool finished;
  9. do
  10. {
  11. cout << "Enter <1> if you want to start over ";
  12. cin >> userChoice;
  13. if (userChoice == 1)
  14. {
  15. finished = true;
  16. }
  17. else
  18. {
  19. finished = false;
  20. }
  21. }
  22. done = false;
  23. cout << " Enter Orange county or Seminole county ";
  24. while (done == false)
  25. {
  26. cin >> num1;
  27. cin >> num2;
  28.  
  29. done = false;
  30. cout << " Incorrect. Please try again. ";
  31. }
  32.  
  33. }
  34. while (finished == false);
  35. return 0;
Last edited by WolfPack; Sep 22nd, 2006 at 9:44 am. Reason: Added [CODE][/CODE] tags
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 275
Reputation: andor has a spectacular aura about andor has a spectacular aura about andor has a spectacular aura about 
Solved Threads: 29
andor's Avatar
andor andor is offline Offline
Posting Whiz in Training

Re: Urgent Porgramming help needed

 
1
  #2
Sep 22nd, 2006
First of all your code doesn't compile without errors. Fix the errors.
If you want to win, you must not loose (Alan Ford)
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 25
Reputation: hoosier23 is an unknown quantity at this point 
Solved Threads: 1
hoosier23 hoosier23 is offline Offline
Light Poster

Re: Urgent Porgramming help needed

 
1
  #3
Sep 22nd, 2006
you need

  1. #include <iostream>
at the top of your program
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 234
Reputation: FireSBurnsmuP is an unknown quantity at this point 
Solved Threads: 1
FireSBurnsmuP's Avatar
FireSBurnsmuP FireSBurnsmuP is offline Offline
Posting Whiz in Training

Re: Urgent Porgramming help needed

 
1
  #4
Sep 22nd, 2006
In the prompt for user starting over, your bool finished is assigned true if they want to continue. Although this works, you might consider renaming it to bool continue, just for clarity's sake.

Shouldn't you put the whole program in a while loop, with (finished == true) as the condition, then at the end of the loop prompt for bool finished? Because the way you have it right now makes the prompt happen indefinately (in what appears to be an infinite loop), then you have a loop for the counties, without the prompt to continue.
Your do ends with the curly brace above done=false;, but the while that you want at the end is not at the end of do, but at the end of the program.

also, your prompt for the counties inputs the numbers, but then assumes that they entered something incorrectly, so it will never do anything but keep prompting for numbers saying you gave it something incorrect.

I hope this stimulates your figuring out process, because I don't want to tell you how to program, but I can give you a start in the right direction.
Last edited by FireSBurnsmuP; Sep 22nd, 2006 at 2:47 pm. Reason: I missed something
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC