need help

the program i have is running it has the calculations right. but im trying to get the program to display all the numbers of cars entered, total for all cars and average of all cars at the same time when user wants to end program. what do i write?

code:

#include <iostream>
#include <math.h>
#include <string>
using namespace std;

int main ()
{
double hOurs = 0;
double chrGe = 0;
int userChoice;


cout << "Please enter number of hours parked: ";
cin >> hOurs;


if(hOurs <= 3)
{
chrGe = 6;
}
else if(hOurs >= 24)
{
chrGe = ((hOurs - remainder (hOurs, 24)) / 24)* 35;
chrGe += (remainder (hOurs, 24))* 2.5;
}
else
{
chrGe = 6;
chrGe += (hOurs - 3)* 2.5;
}

cout << "Summary: " << endl;
cout << "Number of hours: " << hOurs << endl;
cout << "Total charged: $" << chrGe << endl;




system("pause");
return 0;

}
closed account (48T7M4Gy)
You'll need something like a while loop to wrap around nearly all the code you have. The while loop could get an answer from the user 'Y' or 'N' to 'do they want to continue?', or ' is this the last car?'. And as all that happens you need to create variables to accumulate the individual inputs so you can calculate the number of cars, totals and averages etc.
ok how do you put it?
closed account (48T7M4Gy)
Refer to your other two or three simultaneous posts. :(
closed account (1CfG1hU5)
use code tags when pasting code

http://www.cplusplus.com/articles/z13hAqkS/
closed account (1CfG1hU5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <math.h> 
#include <string> 
using namespace std;

int main ()
{
double hOurs = 0;
double chrGe = 0;
int userChoice;


cout << "Please enter number of hours parked: ";
cin >> hOurs;


if(hOurs <= 3)
{
chrGe = 6;
}
else if(hOurs >= 24)
{
chrGe = ((hOurs - remainder (hOurs, 24)) / 24)* 35;
chrGe += (remainder (hOurs, 24))* 2.5;
}
else
{
chrGe = 6;
chrGe += (hOurs - 3)* 2.5;
}

cout << "Summary: " << endl;
cout << "Number of hours: " << hOurs << endl;
cout << "Total charged: $" << chrGe << endl;




system("pause");
return 0;

}


this easier to read
Topic archived. No new replies allowed.