Please write program for the assignment below. Follow all instructions including
ID: 3682633 • Letter: P
Question
Please write program for the assignment below. Follow all instructions including the notes data included. Don't worry about submission part or extra credit. You can use the data under running to make sure the code works. also please make sure code is in c++ and include algorithm.
Project 3 – Parking Deck Ticketing System
Objectives:
1.Make use of if statements to solve a problem.
2.Make use of input and output statements to model a real world application
3.Format output properly
4.Make use of functions to divide up parts of a problem
Instructions:
Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then ask you what time the car left the parking deck. You should then calculate the time that has passed between issuing the time ticket and the time the car left. Lastly, you will use this information to determine how much the person needs to pay upon leaving the deck. The rates are in the table below. Please read through all of the notes below!
You should write a single function for each of the following things:
Reading in the arrival times and departure times
Calculate the passage of time
Determine how much the driver needs to pay
Print out the receipt for the driver, including his arrival and departure times, time in the deck, and how much he owes.
Notes:
Time should be handled in the 24 hour format for simplicity. In addition, you should have the user input the hours, then input the minutes as two separate variables. Please have the user enter hours ranging from 0 to 23, and minutes ranging from 0 to 59.
You may assume that the parking deck is open 24/7 for simplicity. You do not need to worry about times the deck closes for this project.
If the driver has a special parking pass, please enter the time of 99 for the hour and 99 for the minutes when entering the deck. This should be used as a code for the system to know that this person has a special parking pass.
If the drive has lost their ticket, please input 55 for the hour and 55 for the minutes when exiting the deck. This will prompt the system to handle the payments without a ticketing stub.
Please make sure that the output is attractive and informative. It should include, but is not limited to: the time the ticket was issued the time the ticket was entered back into the machine (time the driver exited the deck.) You should also include the amount of time that transpired while the driver was in the deck and the amount of money the driver has to pay. Please use proper formatting techniques for output (fixed and set precision, remember we are talking about money.)
Rate Table:
Time in Parking Deck
Rate in Dollars ($)
Less than or equal to 30 minutes
3.00
[30 Minutes – 1 Hour)
5.00
[1 Hour – 2 Hours )
10.00
[2 Hours – 3 Hours )
15.00
[3 Hours – 4 Hours )
30.00
Each half hour over four hours
30.00 + 5.00 per additional half hour
[12 Hours – Hours )
Error prints out, see notes above.
Lost ticket
110.00
Special Parking Pass
5.00
Running:
Please run the following sets of data:
Entrance Hour
Entrance Minute
Exit Hour
Exit Minute
Run 1
00
00
00
30
Run 2
05
45
07
00
Run 3
06
32
09
54
Run 4
09
15
12
15
Run 5
09
32
14
35
Run 6
08
00
10
30
Run 7
08
45
55
55
Run 8
99
99
99
99
Run 9
9
10
23
30
Submitting:
Please include this document at the front of your project folder. This should be followed by the algorithm for your program. Next please include your source code, followed by all of your output. Lastly, please include your academic honesty promise. Please print all of these and bind them into your project folder. Turn in on the due date.
Extra Credit (5 points):
What happens if you were to arrive at 5:00 PM and leave at 4:00 AM? Would your program still run this correctly? Make sure that you can account for this sort of issue. Add data to test this situation.
Time in Parking Deck
Rate in Dollars ($)
Less than or equal to 30 minutes
3.00
[30 Minutes – 1 Hour)
5.00
[1 Hour – 2 Hours )
10.00
[2 Hours – 3 Hours )
15.00
[3 Hours – 4 Hours )
30.00
Each half hour over four hours
30.00 + 5.00 per additional half hour
[12 Hours – Hours )
Error prints out, see notes above.
Lost ticket
110.00
Special Parking Pass
5.00
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
int passageOfTime(int eh,int em,int dh, int dm){
int h = dh-eh;
int m = dm-em;
return (h*60)+m;
}
int readTime(){
int eh,em,dh,dm;
cout << "Enter the enterance hour" << endl;
cin >> eh;
cout << "Enter the enterance minute" << endl;
cin >> em;
cout << "Enter the exit hour" << endl;
cin >> dh;
cout << "Enter the exit minute" << endl;
cin >> dm;
return passageOfTime(eh,em,dh,dm);
}
double pay(int min){
double r;
if(min<30)
r = 3;
else if(min>=30 && min < 60)
r = 5;
else if(min>=60 && min < 120)
r = 10;
else if(min>=120 && min < 180)
r = 15;
else if(min>=180 && min < 240)
r = 30 + 5*((min-240)/30);
return r;
}
void display(double p){
cout << "Payment amount : " << p << endl;
}
int main()
{
int duration = readTime();
cout << "Duration:" << duration << endl;
double r = pay(duration);
display(r);
}