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
|
/* Purpose: This program is a Parking Deck Ticketing System. Punch in your arrival time
(hours then minutes) and your departure time (hours then minutes). If you lost
your parking ticket, input the values of 55; if you have a special parking pass,
select 99 for all values. Make sure you stay within the range. Enjoy!
*/
#include <iostream>
#include <iomanip>
using namespace std;
double H_out, H_in, M_out, M_in, Time_passed(0), cost(0);
void getTime (double & H_out, double & H_in, double & M_out, double & M_in)
{
cout<< "For Special Ticket Holders only, input 99 for arrival hour and arrival minute" << endl;
cout<< "If ticket has been misplaced, input 55 for departure hour and departure minute:" << endl;
cout<< "Input arrival time in hours in the 0 - 24 hour range" << endl;
cin>>H_in;
cout<< "Input arrival time in minutes in the 0 - 59 minute range" << endl;
cin>>M_in;
cout<< "Input departure time in hours in the 0 - 24 hour range" << endl;
cin>>H_out;
cout<< "Input departure time in hours in the 0 - 24 hour range" << endl;
cin>>M_in;
}
double timePassage()
{
if (H_out >= H_in)
Time_passed = (H_out + M_out/60) - (H_in + M_in/60);
else if (H_out < H_in)
Time_passed = (24-(H_in + M_in/60)) + (H_out + M_out/60);
return Time_passed;
}
double PriceCalculation()
{
if (H_out == 55 && M_out == 55)
cost = 110.00;
else if (H_out == 99 && M_out == 99)
cost = 5.00;
else if (Time_passed < 0.5)
cost = 3.00;
else if (Time_passed < 1)
cost = 5.00;
else if (Time_passed < 2)
cost = 10.00;
else if (Time_passed < 3)
cost = 15.00;
else if (Time_passed < 4)
cost = 30.00;
else if (Time_passed >= 4 && Time_passed < 12)
cost = 30.00 + (Time_passed - 4)*10;
else if (Time_passed >= 12)
cout << "Error" << endl;
else
{
cout << "There was an error, your value(s) were incorrect!" << endl;
cost = 0.00;
}
return cost;
}
void printoutReciept()
{
cout << "Your time of arrival is:" << setfill('0') << setw(2) << H_in << ":" << setfill ('0') << setw(2) << M_in << endl;
cout << "Your time of departure is:" << setfill('0') << setw(2) << H_out << ":" << setfill ('0') << setw(2) << M_out << endl;
cout << "Your amount of time parked is:" << Time_passed << "Hours" << endl;
cout << "Your bill is $" << fixed << setprecision(2) << cost << endl;
}
int main()
{
cout << "This is Paye Kialain's Parking Meter; Enjoy!" << endl;
getTime (H_out, H_in, M_out, M_in);
timePassage();
PriceCalculation();
printoutReciept();
cout << "coded by Paye W. Kialain" << endl;
system("PAUSE");
return 0;
}
|