#include <iostream>
using namespace std;
#include <iomanip>
const double minimumFee = 7.00;
const double hourlyFee = 1.75;
const int numOfCustomers = 12;
const int numOfMinsPerHour = 60;
void inputAndValidate(int&,int&,int&,int&);
void convertToMinutes(int&,int,int);
void convertBackToTime(int&,int,int);
double calcCharge(int,int,int);
int main()
{
int entranceMinutes,exitMinutes,entranceTimeInMins,exitTimeInMins ;
int minutesParked,parkedMinutes,entranceHour,exitHour,parkedTime ;
int parkedHours;
double charge ,totalCharges;
int numOfCustomers = 12;
while(numOfCustomers <= 12)
{
inputAndValidate(entranceHour,entranceMinutes,exitHour,exitMinutes);
convertToMinutes(minutesParked,entranceTimeInMins,exitTimeInMins);
convertBackToTime(parkedTime,parkedMinutes,parkedHours);
//calcCharge(hours,additionalhours,charge);
cout<<"Customer"<<setw(10)<<"Entry Time"<<setw(10)<<"Exit Time"
<<setw(10)<<"Parked Time"<<setw(10)<<"Charge"<<endl;
<<"\n1"<<setw(5)<<entranceHour"h"entranceMinutes<<setw(5)
<<exitHour"h"exitMinutes<<setw(5)<<parkedTime<<setw(5)
<<calcCharge(charge)<<endl;
}
return 0;
}
for (int num = 1; num <= numOfCustomers; i++ )
{
void inputAndValidate (int& entranceHour,int& exitHour,int& entraceMinutes,int& exitMinutes)
{
if((0<entranceHour && exitHour <= 24) && (0<entranceMinutes && exitMinutes <=59))
{
cout<<"Input the time you entered the garage"<<endl;
cin>>entranceHour && entranceMinutes;
cout<<"input the time you left the garage"<<endl;
cin>>exitHour && exitMinutes;
}
else{
cout<<"Input the valid time"<<endl;
}
if(entranceHour == 24)
entranceMinutes = 00;
if(exitHour == 24)
exitMinutes =00;
}
void convertToMinutes(int& minutesParked,int entranceTimeInMins,int exitTimeInMins)
{
int entraceTimeInMins = (entranceHour * numOfMinsPerHour + entranceMinutes);
int exitTimeInMins = (exitHour * numOfMinsPerHour + exitMinutes);
int minutesParked = (exitMinutes - entranceMinutes);
}
void convertBackToTime(int& parkedTime,int& parkedMinutes,int& parkedHours)
{
int parkedHours = (minutesParked / numOfMinsPerHour);
int parkedMinutes = (minutesParked % numOfMinsPerHour);
int parkedTime = (parkedHours && parkedMinutes);
}
double calcCharge(int additionalHourMin ,int additionalHours ,double charge)
{
if ((3>parkedHours<=24) && (0>parkedMinutes<=59)){
int additionalHourMin = (parkedHours - 2);
double charge = (additionalHourMin * hourlyFee + minimumFee);
return charge;
}
else
if((3>parkedHours<=24) && (parkedMinutes = 0)){
int additionalHours = (parkedHours - 3);
double charge = (additionalHours * hourlyFee + minimumFee);
return charge;
}
if(hours == 3){
double charge = minimumFee;
return charge;
}
}
}
clyo cleopas 0 Newbie Poster
thines01 401 Postaholic Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.