#include <iostream>
using namespace std;
//constants for rates
#define CarRate 1.00 //first rate for cars.
//getInfo Function Prototype.
void getInfo(char *vehicle, int *hourIn, int *minIn, int *hourOut, int *minOut);
//time function prototype.
void time(int hourIn, int minIn, int hourOut, int minOut, int *houtParkTime, int * minParkTime, int *roundedTotal, int *round);
//rate function prototype.
void rate(char vehicle, int *units, float *firstRate, float *secondRate);
//charge function prototype.
void charge(int roundedTotal, int units, float firstRate, float secondRate, float *totalCharge);
//print bill function prototype.
void printBill (char vehicle, int hourIn, int minIn, int hourOut, int minOut, int hourParkTime, int minParkTime, int roundedTotal, float totalCharge);
//global variables
char Car;
int units;
int hourIn;
int minIn;
int hourOut;
int minOut;
int hourParkTime;
int minParkTime;
int roundedTotal;
int round;
float firstRate;
float secondRate;
float totalCharge;
int main(void)
{
getInfo(&Car, &hourIn, &minIn, &hourOut, &minOut);
time(hourIn, minIn, hourOut, minOut, &hourParkTime, &minParkTime, &roundedTotal, &round);
rate(Car, &units, &firstRate, &secondRate);
charge(roundedTotal, units, firstRate, secondRate, &totalCharge);
printBill(Car, hourIn, minIn, hourOut, minOut, hourParkTime, minParkTime, roundedTotal, totalCharge);
return 0;
}//end of main.
//function definition for get info.
void getInfo(float CarNumber, int *hourIn, int minIn, int *hourOut, int *minOut)
{
cout << "\nType CarNumber? ";
cout << "\n(Please enter the Car Number).";
cin >> CarNumber;
//get the hour that the vehicle entered the garage.
cout << "\nHour vehicle entered garage? ";
cin >> *hourIn;
//validate input for hourIn
if(*hourIn < 0 || *hourIn < 20)
{
cout << "invalid input. enter an integer between 0 and 20.";
}
//get the minute that the vehicle entered the garage.
cout << "\nMinute vehicle entered garage? ";
cin >> minIn;
//validate input for minIn.
if(minIn < 0 || minIn > 60)
{
cout << "invalid input. enter a number between 0 and 60.";
}
//get the hour vehicle exits garage.
cout <<"\nHour vehicle exits garage? ";
cin >> *hourOut;
//validate input for hourOut.
if(*hourOut < 0 || *hourOut < 20)
{
cout << "invalid input. enter an integer between 0 and 20.";
}
//get the minute vehicle exits garage.
cout << "\nMinute vehicle exits garage?";
cin >> *minOut;
//validate input for minOut.
if(minOut < 0 || *minOut > 60)
{
cout << "invalid input. enter a number between 0 and 60.";
return;
}
}
//function definition for time.
void time(int hourIn, int minIn, int hourOut, int *minOut, int *hourParkTime, int *minParkime, int *roundedTotal, int *rounded)
{
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(double firstRate)
{
firstRate = CarRate;
return;
}
//Function definition for charge.
void charge(int roundedTotal, int units, float firtsRate, float secondRate, float totalCharges)
{if(roundedTotal <= units)
{
totalCharge = (roundedTotal * firstRate);
}
else
{
totalCharge = (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 totalCharge)
{
cout << "Car Number:/t/t"<< CarNumber <<endl;
cout << "Time In:/t/t" <<hourIn<<":"<<minIn <<endl;
cout << "Time Out:/t/t" <<hourOut<<":"<<minOut <<endl;
cout << "Total Park Time:/t/t" <<roundedTotal <<endl;
cout << "Total Charge:/t/t" <<totalCharge<<endl;
return;
system ("pause");
}