| | |
I need to write a C++ Code from the following info. HOW DO I...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2004
Posts: 5
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2005
Posts: 1
Reputation:
Solved Threads: 0
Here you go I hope this helps!!!
<< moderator edit: added code tags: [code][/code] >>
C++ Syntax (Toggle Plain Text)
//Chapter 3 in C++ Programming //Parking Garage //Author Robert Capetillo 8-12-05 #include <iostream> using std::cout; using std::cin; using std::endl; using std::fixed; #include <iomanip> using std::setw; using std::setprecision; int main() { int count; int x; double charge; double a; double b; double c; cout<< "Enter the number of Hours: "; cin >> a >> b >> c; cout<< setw(5)<< "Car" << setw(10)<< "Hours" << setw(15)<< "Charge\n"; cout << fixed << setprecision (2); count = 1; while ( count <=3 ) { if (count == 3) x = c; else if (count == 2) x = b; else if (count == 1) x = a; if (x <= 3) charge = 2; else if (x >19) charge = 10; else if (x > 3) charge = 2 + (x - 3) * (.5); cout <<setw(5) << count<< setw(10) << x << setw(10)<< "$"<<charge <<"\n"; count = count + 1;} return 0; }
![]() |
Similar Threads
- Can we Programaticall Write code in VB6.0, forms/standard module/class code window (Visual Basic 4 / 5 / 6)
- Could Somebody Write Code Plz... (Visual Basic 4 / 5 / 6)
- How do you write a code which compiles in c but not in c++? (C++)
Other Threads in the C++ Forum
- Previous Thread: C++ linking problem
- Next Thread: problem with tic-tac-toe! help.
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets




