K
Keith
Ok, so here is the code I have so far........my question is whether it is
possible to hold onto the amount of hours for each car entered without
erasing it through the next entry. I need a table format like this to appear
at the end with a total for all three cars. How do I handle this?
Table:
Car Hrs Rate
Code:
// Program computes charges for parked cars and returns daily total
#include <iostream>
#include <conio.h>
#include <cmath>
using std::cout;
using std::cin;
double calculateCharges ( double ); // function prototype
// Explanation of function calculateCharges
double calculateCharges(double hrs)
{
//double hrs;
double charge;
double extracharge;
double result;
charge = 2.00; // first 3 hours of parking cost $2.00
extracharge = charge + (hrs * .50); // any hour (or part therof) after 3
costs .50
result = charge;
if(hrs > 3.0) result = extracharge;
if(hrs > 24.0) result = 10.00;
return result;
}
//function main begins program execution
int main;
int car1;
int car2;
int car3;
double hrs;
cout << "Enter the amount of hours parked :";
cin >> hrs >> car1;
cout << "Enter the amount of hours parked :";
cin >> hrs >> car2;
cout << "Enter the amount of hours parked :";
cin >> hrs >> car3;
Thanks!
possible to hold onto the amount of hours for each car entered without
erasing it through the next entry. I need a table format like this to appear
at the end with a total for all three cars. How do I handle this?
Table:
Car Hrs Rate
1 3 2.00
2 4.0 2.50
3 24 10.00
Totals: 31 14.50
Code:
// Program computes charges for parked cars and returns daily total
#include <iostream>
#include <conio.h>
#include <cmath>
using std::cout;
using std::cin;
double calculateCharges ( double ); // function prototype
// Explanation of function calculateCharges
double calculateCharges(double hrs)
{
//double hrs;
double charge;
double extracharge;
double result;
charge = 2.00; // first 3 hours of parking cost $2.00
extracharge = charge + (hrs * .50); // any hour (or part therof) after 3
costs .50
result = charge;
if(hrs > 3.0) result = extracharge;
if(hrs > 24.0) result = 10.00;
return result;
}
//function main begins program execution
int main;
int car1;
int car2;
int car3;
double hrs;
cout << "Enter the amount of hours parked :";
cin >> hrs >> car1;
cout << "Enter the amount of hours parked :";
cin >> hrs >> car2;
cout << "Enter the amount of hours parked :";
cin >> hrs >> car3;
Thanks!