I need to write a C++ Code from the following info. HOW DO I...

Please support our C++ advertiser: Intel Parallel Studio Home
Closed Thread

Join Date: May 2004
Posts: 5
Reputation: bryj3 is an unknown quantity at this point 
Solved Threads: 0
bryj3 bryj3 is offline Offline
Newbie Poster

I need to write a C++ Code from the following info. HOW DO I...

 
0
  #1
May 7th, 2004
Hello...
Any idea how to write this in C++ code....
A parking garage chages a $2.00 minimum fee to park up to three hours.
The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no cars park for longer than 24 hours at a time.

How do I write a program that calculates and prints the parking charges for each of the three customers who parked their cars in this garage yesterday.
Entering the hours parked for each customer. The program should print the results in a neat tabular format and should calculate and print the total of yesterday's receipts. The program should use the calculateCharges to determine the charge for each customer. The output should appear in the following format:

Car Hours Charge

1 1.5 2.00
2 4.0 2.50
3 24.0 10.00

Total 29.5 14.50


THANK YOU,
George
Quick reply to this message  
Join Date: Mar 2004
Posts: 77
Reputation: infamous is an unknown quantity at this point 
Solved Threads: 2
infamous infamous is offline Offline
Junior Poster in Training

Re: I need to write a C++ Code from the following info. HOW DO I...

 
0
  #2
May 7th, 2004
read in the number of hours from the user using cin.
if the number is <= 3, then charge is 2
else if the (number of hours - 3) * .50 + 2 > 10, it is $10
else the answer is (number of hours - 3) * .50 + 2
use the cout formatting w/ ios:: crap to tabulate it
Quick reply to this message  
Join Date: May 2004
Posts: 21
Reputation: ze_viru$ is an unknown quantity at this point 
Solved Threads: 0
ze_viru$'s Avatar
ze_viru$ ze_viru$ is offline Offline
Newbie Poster

Re: I need to write a C++ Code from the following info. HOW DO I...

 
0
  #3
May 11th, 2004
i think u should start with a pseudocode first.
Quick reply to this message  
Join Date: May 2004
Posts: 5
Reputation: bryj3 is an unknown quantity at this point 
Solved Threads: 0
bryj3 bryj3 is offline Offline
Newbie Poster

Re: I need to write a C++ Code from the following info. HOW DO I...

 
0
  #4
May 11th, 2004
TO ZE_VIRU$
Hey thanks ZE_VIRU$......I found the code from another sorce. It was a little longer but it worked....THANKS AGAIN
Quick reply to this message  
Join Date: May 2005
Posts: 2
Reputation: schoolgirl05 is an unknown quantity at this point 
Solved Threads: 0
schoolgirl05 schoolgirl05 is offline Offline
Newbie Poster

Re: I need to write a C++ Code from the following info. HOW DO I...

 
0
  #5
May 15th, 2005
i would be interested in knowing how you worked it out if you don't mind
Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: I need to write a C++ Code from the following info. HOW DO I...

 
0
  #6
May 15th, 2005
The last post was 05-11-2004 06:51 PM, over a year ago. Somehow I don't think bryj3 will have saved the code, even if he still hangs around here and sees your post.
Quick reply to this message  
Join Date: Aug 2005
Posts: 1
Reputation: Twin6g72Turbo is an unknown quantity at this point 
Solved Threads: 0
Twin6g72Turbo Twin6g72Turbo is offline Offline
Newbie Poster

Re: I need to write a C++ Code from the following info. HOW DO I...

 
0
  #7
Aug 15th, 2005
Here you go I hope this helps!!!

  1. //Chapter 3 in C++ Programming
  2. //Parking Garage
  3. //Author Robert Capetillo 8-12-05
  4.  
  5. #include <iostream>
  6.  
  7. using std::cout;
  8. using std::cin;
  9. using std::endl;
  10. using std::fixed;
  11.  
  12.  
  13. #include <iomanip>
  14.  
  15. using std::setw;
  16. using std::setprecision;
  17.  
  18.  
  19. int main()
  20. {
  21. int count;
  22. int x;
  23. double charge;
  24. double a;
  25. double b;
  26. double c;
  27.  
  28. cout<< "Enter the number of Hours: ";
  29. cin >> a >> b >> c;
  30.  
  31.  
  32. cout<< setw(5)<< "Car" << setw(10)<< "Hours" << setw(15)<< "Charge\n";
  33.  
  34. cout << fixed << setprecision (2);
  35.  
  36. count = 1;
  37. while ( count <=3 ) {
  38.  
  39. if (count == 3)
  40. x = c;
  41.  
  42. else if (count == 2)
  43. x = b;
  44.  
  45. else if (count == 1)
  46. x = a;
  47.  
  48. if (x <= 3)
  49. charge = 2;
  50.  
  51. else if (x >19)
  52. charge = 10;
  53. else if (x > 3)
  54. charge = 2 + (x - 3) * (.5);
  55.  
  56. cout <<setw(5) << count<< setw(10) << x << setw(10)<< "$"<<charge <<"\n";
  57.  
  58. count = count + 1;}
  59.  
  60. return 0;
  61.  
  62. }
<< moderator edit: added code tags: [code][/code] >>
Quick reply to this message  
Closed Thread

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