Help with my code

Here is the code so far

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 #include <iostream>
#include <string>

using namespace std;

void welcomeMsg()
{
	cout << "Welcome to My Program" << endl << "The program going to calculate the cost of each call you made" << endl;
}


double phoneCost(int& callTime, int& callLength)
{
	int noOfCalls;
	double totalCost = 0.0;


	// calculating the price of phone call

	totalCost = (callLength * 0.10);

	if ((callTime < 800) || (callTime > 1800))
	{

		totalCost = totalCost - (totalCost * 0.50);
	}

	if (callLength > 60)
	{
		totalCost = totalCost - (totalCost * 0.15);
	}

	totalCost = totalCost + (totalCost * 0.04);

	return totalCost;
}


int main()
{

	welcomeMsg();
	cout << endl;

	int accountNum, zipCode, numberOfCalls, callTime, callLength;
	string userName, address, state, city;
	double totalCost = 0.0;


	cout << "Please enter your name: ";
	getline(cin, userName, '\n');

	cout << "Please enter your address: ";
	getline(cin, address, '\n');

	cout << "city: ";
	getline(cin, city, '\n');

	cout << "State: ";
	cin >> state;

	cout << "Zip code: ";
	cin >> zipCode;

	cout << "Please enter your account number: ";
	cin >> accountNum;

	cout << "How many calls do you want to calculate the cost for: ";
	cin >> numberOfCalls;

	for (int j = 0; j < numberOfCalls; j++)
	{
		do
		{
			cout << "Please enter the time of the call as (hhmm), e.g(1830) for (6:30 PM) : ";
			cin >> callTime;
			if ((callTime < 0) || (callTime > 2359))
			{
				cout << "Invalid time entered, please reenter valid time";
			}

		} while ((callTime < 0) || (callTime > 2359));
	}

	for (int k = 0; k < numberOfCalls; k++)
	{
		do
		{
			cout << "Please enter the length of the call as number of minutes: ";
			cin >> callLength;

			if (callLength < 0)
			{
				cout << "Invalid call length, please reenter valid one";
			}
			else if (callLength > 400)
			{
				cout << "Invalid call length, Longest call phone is 400 minutes please reenter valid one";
			}

		} while ((callLength < 0) || (callLength > 400));
	}

	for (int b = 0; b < numberOfCalls; b++)
	{
		totalCost += phoneCost(callLength, callTime);
	}

	cout << endl << "-------------------------------------------------------------------------" << "---------------------------------------------------------------------------------------" << endl;
	// the bill
	
	cout << "Bill to: " << accountNum << endl;
	cout  << userName << endl;
	cout << address << endl << city << ", " << state << ", " << zipCode << endl;

	cout << "------------------------------" << endl;



	cout << "- You made " << numberOfCalls << " calls" << endl << "- All calls are subject to 4% fedral tax";
	cout << endl<< endl << "Total cost of your calls is: " << totalCost << "$" << endl;

	system("PAUSE");
	return 0;
}



I want to show each call with when it started, the length and the cost before the total cost like this :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
	cout << "Bill to: " << accountNum << endl;
	cout  << userName << endl;
	cout << address << endl << city << ", " << state << ", " << zipCode << endl;

	cout << "------------------------------" << endl;

 - call 1 , start time , duration , cost
 - call 2 , start time , duration , cost


	cout << "- You made " << numberOfCalls << " calls" << endl << "- All calls are subject to 4% fedral tax";
	cout << endl<< endl << "Total cost of your calls is: " << totalCost << "$" << endl;

	system("PAUSE");
	return 0;
}


and so on for how many calls the user enter, what should i do
Q. Where did you store the data for each call?
A. You didn't.

You need a container for the calls. See std::vector.
Topic archived. No new replies allowed.