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
|
#include <iostream>
#include <iomanip>
using namespace std;
void times(int& arriveH, int& arriveM, int& departH, int& departM)
{
cout<<"What is the hour of the time of arrival based on the 24 hours system?"<<endl;
cout<<"Example: Enter 00 for 12:00 AM"<<endl;
cout<<" "<<endl;
cin>>arriveH;
cout<<"What is the minute of the time of arrivalbased on the 24 hours system??"<<endl;
cout<<"Example: Enter 59 for 12:59 AM"<<endl;
cout<<" "<<endl;
cin>>arriveM;
cout<<"What is the hour of the time of departure based on the 24 hours system??"<<endl;
cout<<"Example: Enter 00 for 12:00 AM"<<endl;
cout<<" "<<endl;
cin>>departH;
cout<<"What is the minute of the time of arrival based on the 24 hours system??"<<endl;
cout<<"Example: Enter 59 for 12:59 AM"<<endl;
cout<<" "<<endl;
cin>>departM;
}
void timeIn (int arriveH, int arriveM, int departH, int departM, int& timeSpentH, int& timeSpentM)
{
timeSpentH = departH - arriveH;
timeSpentM = departM - arriveM;
}
int amountPay (int timeSpentH, int timeSpentM)
{
int paymentDue;
if(timeSpentH == 55 && timeSpentM == 55)
paymentDue = 5;
if(timeSpentH == 99 && timeSpentM == 99)
paymentDue = 110;
int totalTime = (timeSpentH*60) + timeSpentM;
if(totalTime < 30)
paymentDue = 3;
else if (totalTime == 30 || totalTime < 60)
paymentDue = 5;
else if (totalTime == 60 || totalTime < 120)
paymentDue = 10;
else if (totalTime == 120 || totalTime < 180)
paymentDue = 15;
else if (totalTime == 180 || totalTime <= 240)
paymentDue = 30;
else if (totalTime > 240 && totalTime < 720)
paymentDue = 30 + ((totalTime - 240)/30)*5;
else
cout<<"Error"<<endl;
return paymentDue;
}
void printReceipt (int paymentDue, int arriveH, int arriveM, int departH, int departM, int totalTime)
{
cout<<"Arrival Time: "<<"/t"<<arriveH<<":"<<arriveM<<endl;
cout<<" "<<endl;
cout<<"Departure Time: "<<"/t"<<departH<<":"<<departM<<endl;
cout<<" "<<endl;
cout<<"Total Time: "<<"/t"<<totalTime<<endl;
cout<<" "<<endl;
cout<<"Amount Due: "<<"/t"<<fixed<<setprecision(2)<<paymentDue<<endl;
}
int main()
{
int arriveH, arriveM, departH, departM, timeSpentH, timeSpentM;
times(arriveH, arriveM, departH, departM);
timeIn(arriveH, arriveM, departH, departM, timeSpentH, timeSpentM);
double paymentDue = amountPay (timeSpentH, timeSpentM);
int totalTime = (timeSpentH*60)+(timeSpentM);
printReceipt (paymentDue, arriveH, arriveM, departH, departM, totalTime);
system("pause");
return(0);
}
|