Hey everyone :)
I've been working on the first part of a program which I'm doing in 4 steps.
Here's the first step which I have completed:
Function inputAndValidate
This function inputs the time. The time should be entered as two separate values for the hours and minutes. Do not accept a value of less than 0 or more than 24 for the hour, or a value of less than 0 or more than 59 for the minutes.
Here's what I've done:
# include <iostream>
using namespace std;
void inputAndValidate (int entranceHourP, int entranceMinutesP, int exitHourP, int exitMinutesP)
{
do
{
cout << "Enter the hour and minutes the parking garage was entered (each separated by a space): " << endl;
cin >> entranceHourP >> entranceMinutesP;
}
while((entranceHourP > 0) || (entranceHourP < 24) && ((entranceMinutesP > 0) || (entranceMinutesP < 59)));
do
{
cout << "Enter the hour and minutes the parking garage was exited (each separated by a space): " << endl;
cin >> exitHourP >> exitMinutesP;
}
while((exitHourP > 0) || (exitHourP < 24) && ((exitMinutesP > 0) || (exitMinutesP < 59)));
}
int main()
{
for (int i = 1; i <= 10; i++)
{
int entranceHour, entranceMinutes;
int exitHour, exitMinutes;
int entranceTimeInMins, exitTimeInMins, minutesParked; // will use function to convertToMinutes later
int parkHours, parkedMinutes; // will use function to convertBackTime later (e.g. 570 min = 9h30)
float charge, totalCharges; // will use function calcCharge later
inputAndValidate(entranceHour, entranceMinutes, exitHour, exitMinutes);
system("pause");
return 0;
}
}
The compiler error I get using MS Visual Studio is this: The variable exitMinutes is being used without being initialised. ??
Anyone know why this is happening ?