Question

I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if,...

I need help in C++ .

Project 3 – Parking Deck Ticketing System

Objectives:

Use if, switch, and loop statements to solve a problem.

Use input and output statements to model a real world application

Incorporate functions to divide the program into smaller segments

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 player needs to pay

Print out the receipt for the user. Including their arrival and departure times, time in the deck and how much they owe.

Notes:

Time should be handled in the 24 hour format for simplicity. In addition, you should put the data on a file with the hours and the minutes as two separate variables separated by a space. Please have the hours ranging from 0 to 23, and minutes ranging from 0 to 59 with a blank in between hours and minutes. See the second table below for the data.

You may assume that the parking deck is open 24/7 for simplicity. You do not need to worry about times the deck closes and such for this project.

If the drive 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 drive 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 due to pay back. 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 <= 12 hours

30.00 + 5.00 per additional half hour

>12 Hours <= 24 Hours )

Error prints out, see notes above.

Lost ticket

110.00

Special Parking Pass

5.00

Running:

Please run the following sets of data from an input file:

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

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 put all of these documents in a zipped folder and submit to D2L.

Extra Credit:

What happens if you were to arrive at 5:00 PM and leave at 4:00 AM? Would you program still run this correctly? Make sure that you can account for this sort of issue.

More Information on Project 3

If the ticket is lost (code 99), charge the patron $110.00.
If the patron has a parking pass (code 55), the charge is $5.00.
If the ticket shows more than 12 hours in the parking deck, print ERROR in the column where the charge usually goes.
If you do the extra credit (in at 17:00 hours (5PM)and out at 4:00 (4AM)), the charge will be $100.00 for 11 hours.
Present the answers in a table with column headings of entry hours & min (could be 99), exit hours & min (could be 99 or 55), total minutes in the parking deck (leave blank for codes of 99 and 55), and total cost of parking.

Answers are: 3.00, 10.00, 30.00, 15.00, 45.00, 15.00, 110.00, 5.00, ERROR, and 100.00(extra credit).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: In case of any queries, just comment in box I would be very happy to assist all your queries

Program Screenshot:

// Header files #include<iostream> #include <math> Hinclude <string> using namespace::std; // main function int main() // Dec

J/ Less than 30 minutes if (time <= 30) return 3; // Between 30 Minutes - 1 Hour if (time <= 60) return 5; //Between 1 Hour -

Sample Output:

Run 1: ter in-time Sura: 00 Enter out-time QUES: 00 In-time! 0:0 It-tie:0:30 Total-time: 303 Eare la 63 Enter in-time Our : 0

Code to copy:

// Header files
#include<iostream>
#include<cmath>
#include<string>
using namespace::std;

// main function
int main()
{
   // Declare the variables
   int time_Inhour, time_Inmin, time_Outhour,time_Outmin, time, price;

   // Function prototypes
   void read_arr_dep_Times(int*, int*, string);
   int cal_Passage_Time(int, int, int, int);
   int cal_Pay(int);
   void print_User_Receipt(int, int, int,int, int, int);

   // call the read_arr_dep_Times() function
   read_arr_dep_Times(&time_Inhour, &time_Inmin,"in-time");
   // call the read_arr_dep_Times() function
   read_arr_dep_Times(&time_Outhour, &time_Outmin,"out-time");
   // call the cal_Passage_Time() function
   time = cal_Passage_Time(time_Inhour, time_Inmin,time_Outhour, time_Outmin);
   // call the cal_Pay() function
   price = cal_Pay(time);
   // call the print_User_Receipt() function
   print_User_Receipt(time_Inhour, time_Inmin, time_Outhour, time_Outmin, time, price);
   //system("pause");
   return 0;

}

// Reading in the arrival times
//and departure times
void read_arr_dep_Times(int* hour, int* minute, string s)
{
   cout << "Enter " << s << " \nhours: ";
   cin >> *hour;
   // Hours ranging from 0 to 23 and minutes
   //ranging from 0 to 59.
   while ((*hour < 0 || *hour > 23) && *hour != 55 && *hour != 99)
   {
       cout << "Wrong input!(Please enter Hour can be between 0-23): ";
       cin >> *hour;
   }
   if (*hour == 55 || *hour == 99)
   {
       *minute = *hour;
       return;
   }
   cout << "min: ";
   cin >> *minute;
   while (*minute < 0 || *minute > 59)
   {
       cout << "Wrong input!(Please enter Minutes can be between 0-59): ";
       cin >> *minute;
   }
}

//Calculate the passage of time
int cal_Passage_Time(int time_Inhour,int time_Inmin, int time_Outhour, int time_Outmin)
{
   //Check the input 55 for the hour
   // and 55 for the minutes
   if (time_Outhour == 55 && time_Outmin == 55)
       return -2;
   //Check the input time of 99 for the hour
   //and 99 for the minutes
   if (time_Inhour == 99)
       return -1;
   if (time_Inhour <= time_Outhour)
       return (time_Outhour - time_Inhour)   * 60 + time_Outmin - time_Inmin;

   return (time_Outhour + 24 - time_Inhour)* 60 + time_Outmin - time_Inmin;

}

//Determine how much the player needs to pay
int cal_Pay(int time)
{
   //Check the drive has a special parking pass
   if (time == -1)
       return 5;
   // Check the drive has lost their ticket
   if (time == -2)
       return 110;
   // Less than 30 minutes
   if (time <= 30)
       return 3;
   // Between 30 Minutes – 1 Hour
   if (time <= 60)
       return 5;
   //Between 1 Hour – 2 Hours
   if (time <= 120)
       return 10;
   //Between 2 Hours – 3 Hours
   if (time <= 180)
       return 15;
   //Between 3 Hours – 4 Hours
   if (time <= 240)
       return 30;
   //Each half hour over four hours
   if (time <= 720)
       return 30 + ceil((time - 240) / 30) * 5;
   //error
   return -1;
  
}

//Print out the receipt for the user.
void print_User_Receipt(int time_Inhour, int time_Inmin,int time_Outhour, int time_Outmin, int time, int fare)
{
   //Check the drive has a special parking pass
   if (time_Inhour == 99)
       cout << "The person has a special parking pass.Fare is $" << fare << endl;
   // Check the drive has lost their ticket
   else if (time_Outhour == 55)
       cout << "In-time: " << time_Inhour<< ":" << time_Inmin << endl
       << "The drive has lost their ticket\nFare is: $" << fare << endl;
   else
       cout << "In-time: " << time_Inhour<< ":" << time_Inmin << endl << "Out-time:"<< time_Outhour << ":" << time_Outmin << endl    << "Total-time: " << time << "mins" << endl   << "Fare is $" << fare << endl;
}

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Objectives: 1. Use if, switch, and loop statements 2. Use input and output statements 3. Incorporate...

    Objectives: 1. Use if, switch, and loop statements 2. Use input and output statements 3. Incorporate functions to divide the program into smaller segments 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...

  • Parking Ticket Simulator C++ HELP PLEASE

    For this assignment you will design a set of classes that work together to simulate a police officer issuing a parking ticket. The classes you should designare:• The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are:o To know the car’s make, model, color, license number, and the number of minutes that the car has been parked• The ParkingMeter Class: This class should simulate a parking meter. The class’s only responsibility is:o To know the number...

  • Use the description from Parking Ticket Simulator from Chapter 14 as a basis, where you need...

    Use the description from Parking Ticket Simulator from Chapter 14 as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example in the PPT) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked beyond their time...

  • C programming Construct a console program to simulate Zoo ticketing system. The system is used for...

    C programming Construct a console program to simulate Zoo ticketing system. The system is used for dispensing tickets to customers. In order to buy tickets, the customer need to enter the following information: a) Number of ticket they want to buy. Everybody must have a ticket to enter. b) Only up to 5 tickets may be purchased for every transaction or customer. c) Type of ticket either for adult, children (aged 5 12 years old) or toddler (aged 2-5 years...

  • need help with c++ project: For the project. Create a c++ program about bus booking and...

    need help with c++ project: For the project. Create a c++ program about bus booking and ticketing system that - This system also needs you to key in your username and password precisely and ask again to confirm your booking of the bus ticket, and output of the ticket fully displayed -Must include selections, looping and functions, and array. - minimum of 6 functions including main function Keywords that should not be in the source code: class, struct, fstream, ifstream,...

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • I need help with this java project and please follow the instruction below. thank Class Project...

    I need help with this java project and please follow the instruction below. thank Class Project - Parking Ticket simulator Design a set of classes that work together to simulate a police officer issuing a parking ticket. Design the following classes: •           The ParkedCar Class: This class should simulate a parked car. The class’s responsibilities are as follows: – To know the car’s make, model, color, license number, and the number of minutes that the car has been parked. •          ...

  • Need some assistance of reorganizing this whole program. I have the right code for everything I...

    Need some assistance of reorganizing this whole program. I have the right code for everything I just need help on putting all the codes in the right spot so it can come out to the correct output. output is supposed to look like this: 1 \\ user inputs choice to convert 12 to 24 8 \\ user inputs 8 for hours 30 \\ user inputs 30 for minutes 20 \\ user inputs 20 for seconds AM \\ user inputs AM...

  • PLEASE I NEED C# Objectives Learn the basics of exception handling. Background Exceptions are essentially unexpected...

    PLEASE I NEED C# Objectives Learn the basics of exception handling. Background Exceptions are essentially unexpected situations. It is difficult to write a program that can handle all possible situations, as we have found out through the many programs we have written. For example, should your program accept accidental input? Does it use the metric system or the empirical system? Do users of your program know which system it uses? In order to deal with all these possibilities, exceptions were...

  • Chapter 9 Lab Text Processing and Wrapper Classes Lab Objectives ? Use methods of the Character...

    Chapter 9 Lab Text Processing and Wrapper Classes Lab Objectives ? Use methods of the Character class and String class to process text ? Be able to use the StringTokenizer and StringBuffer classes Introduction In this lab we ask the user to enter a time in military time (24 hours). The program will convert and display the equivalent conventional time (12 hour with AM or PM) for each entry if it is a valid military time. An error message will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT