Need help with multiple function calls.

I can't get the program to work past the vehicle type function. If I try return(1), return(2), etc... I get errors. I'm stumped.

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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <iostream>
using namespace std;

#define firstCarRate 0.00
#define secondCarRate 1.25
#define firstTruckRate 3.75
#define secondTruckRate 4.50
#define firstBusRate 2.00
#define secondBusRate 2.50

void getUserInfo(char*vehicle, int*hourIn, int*minIn, int*hourOut, int*minOut);
void time(int hourIn, int minIn, int hourOut, int minOut, int*hourParkTime, int*minParkTime, int*roundedTotal, int*rounded);
void rate(char vehicle, int*units, float*firstRate, float*secondRate);
void charges(int roundedTotal, int units, float firstRate, float secondRate, float*totalCharges);
void printBill(char vehicle, int hourIn, int minIn, int hourOut, int minOut, int hourParkTime, int minParkTime, int roundedTotal, float totalCharges);

char vehicle = 'C';
int units;
int hourIn; 
int minIn; 
int hourOut;
int minOut;
int hourParkTime; 
int minParkTime; 
int roundedTotal; 
int round; 
float firstRate; 
float secondRate; 
float totalCharges;

int main()
{
	getUserInfo(&vehicle, &hourIn, &minIn, &hourOut, &minOut);
	time(hourIn, minIn, hourOut, minOut, &hourParkTime, &minParkTime, &roundedTotal, &round);
	rate(vehicle, &units, &firstRate, &secondRate);
	charges(roundedTotal, units, firstRate, secondRate, &totalCharges); 
	printBill(vehicle, hourIn, minIn, hourOut, minOut, hourParkTime, minParkTime, roundedTotal, totalCharges);
	return 0;
}//main

//function definition for get info.
void getUserInfo(char*vehicle, int*hourIn, int*minIn, int*hourOut, int*minOut)
{
	cout << "\nType of vehicle? ";
	cout << "\n(enter C/c for car,T/t for truck or B/b for bus).";
	cin >> vehicle;
	//check for valid vehicle type
	{
		switch(*vehicle)
		{
			{
		case 'C': cout << "You entered car.\n";
		case 'c': cout << "You entered car.\n";
			break;
		case 'T': cout << "You entered truck.\n";
		case 't': cout << "You entered truck.\n";
			break;
		case 'B': cout << "You entered bus.\n";
		case 'b': cout << "You entered bus.\n";
			break;
		default: cout << "You did not enter a valid vehicle type\n";
			cout << "Please Enter C,c,T,t,B, or b\n";
			return;
			}

{ //Hour that vehicle entered garage.
	cout << "\nPlease enter hour in:";
	cin >> *hourIn;
	//hourIn validation
	if((*hourIn < 0) || (*hourIn > 23))
	{
		cout << "\nInvalid hour in:"
			<< "\nPlease restart the program.";
	}//Minutes that vehicle entered garage.
	cout << "\nPlease enter minutes in:";
	cin >> *minIn;
	//minIn validation
	if((*minIn < 0) || (*minIn > 59))
	{
		cout << "\nInvalid minutes in"
			<< "\nPlease restart the program.";
	}//Hour that vehicle exited garage.
	cout << "\nPlease enter hour out:";
	cin >> *hourOut;
	//hourOut validation
	if((*hourOut < 0) || (*hourOut > 23))
	{
		cout << "\nInvalid hour out"
			<< "\nPlease restart the program.";
	}//Minutes that vehicle exited garage.
	cout << "\nPease enter minutes out:";
		cin >> *minOut;
	//minOut validation
	if((*minOut < 0) || (*minOut > 59))
	{
		cout << "\nInvalid minutes out"
			<< "\nPlease restart the program.";
		return;
	}
}
		}
	}
}
//Function definition for time
void time(int hourIn, int minIn, int hourOut, int minOut, int*hourParkTime, int*minParkime, int*roundedTotal, int*round)
{
	if (minOut < minIn)
	{
		minOut = minOut + 60;
		hourOut = hourOut - 1;
	}
	else
	{
		*hourParkTime = hourOut - hourIn;
		minParkTime = minOut - minIn;
	}
	if(minParkTime >= 1)
	{
		*round = *hourParkTime + 1;
	}
	else
	{
		*round = *hourParkTime;
	}
	*roundedTotal = *round;
	return;
}

//Function definition for rate.
void rate(char vehicle, int*units, float*firstRate, float*secondRate)
{
	switch(vehicle)
	{
		{
	case 'c':
	case 'C': 
		*firstRate = firstCarRate;
		*secondRate = secondCarRate;
		*units = 3;
		break;
		}
		{
	case 'b':
	case 'B': 
		*firstRate = firstBusRate;
		*secondRate = secondBusRate;
		*units = 2;
		}
		break;
	case 't':
	case 'T': 
		*firstRate = firstTruckRate;
		*secondRate = secondTruckRate;
		*units = 1;
		break;
		{
	default:
		cout << "\nEnter a valid vehicle type.";
		return;
		}
	}
}

//Function definition for charge.
void charges(int roundedTotal, int units, float firstRate, float secondRate, float*totalCharges)
{
	if(roundedTotal <= units)
	{
		*totalCharges = (roundedTotal * firstRate);
	}
	else
	{
		*totalCharges = (roundedTotal - units) * (secondRate) + (units * firstRate);
	}
	return;
}

//Function definition for print Bill.
void printBill(char vehicle, int hourIn, int minIn, int hourOut, int minOut, int hourParkTime, int minParkTime, int roundedTotal, float totalCharges)
{
cout << "Vehicle Type:"<< vehicle << endl;
cout << "Time In:" << hourIn << " : " << minIn << endl;
cout << "Time Out:" << hourOut << " : " << minOut << endl;
cout << "Total Park Time:" << roundedTotal << endl;
cout << "Total Charge:" << totalCharges << endl;
return;
}
Topic archived. No new replies allowed.