Success!

Note

Error

Session expiration Your session is going to expireClick here to extend

Budget:

Small project <800

Posted on

8/24/11 4:23 PM

Buyer:

ken***

This project has expired

Why don't you register anyway? We are sure that you will find many similar projects out of the thousands waiting for you!

Post similar project now

Description

 

PROBLEM#: 1

A parking garage charges a R7.00 minimum fee to park for up to three hours. The   garage charges an additional R1.75 per hour or part thereof in excess of three hours. Assume that no car parks for longer than 24 hours at a time. To determine how long a car was parked, both the entry time and exit time are converted to minutes. The entrance time in minutes is then subtracted from the exit time in minutes, and these minutes are converted back to hours and minutes before the parking fee is calculated.

Write a program that calculates and prints the parking charges for customers who parked in this garage. Twenty customers use the parking garage at any given time. For each customer the program has to:

·        Input the time when the parking garage was entered

·        Input the time when it was exited

·        Convert both the entry and exit time  to minutes

·        Calculate how long the car was parked in minutes (parked time)

·        Convert the parked time in minutes back to time in hours and minutes

·        Calculate the charge (amount owed by the customer)

·        Display the receipt for the customer (display entry and exit times (in 24h00 format, duration for parked time and charge

·        Calculate the total of daily receipts

·        Finally the total amount of all the receipts should be displayed with informative messages

The program should consist of five functions. Declare constants for the number of minutes in an hour, the minimum fee (R7.00), the cut-off time of three hours, the hourly fee of R1.75 and the number of customers (20). Follow the conventions of the Study Guide and prescribed text when writing the program.

Main function()

      Declare the following variables:        

                  entranceHour, entranceMinutes

                  exitHour, exitMinutes

                  entranceTimeInMins, exitTimeInMins, minutesParked;

                  parkedHours, parkedMinutes;

                  charge, totalCharges;

Use a for loop going from 1 to the number of customers. The other four functions should be called inside the for loop

        Function InputAndValidate()

This function inputs the time. The time should be entered as two separate values for the hours and minutes e.g. the customer enters the parking garage at 9h30, the time should be entered as 9 for the hour and 30 for the minutes. Do not accept a value less than 0 or more than 24 for the hour, or a value of less than 0 or more than 59 for the minutes. If this happens a prompting message should be displayed and the values entered repeatedly until they are valid. If a value of 24 has been input for the hour, the minutes should be made 0, regardless of what value the user has entered for the minutes. You have to decide yourself on the type of function and the number of type(s) of the parameters

     Function convertToMinutes()

This function converts the time given in hours and minutes to time in minutes, e.g. 9h30 is converted to 570 minutes. You have to decide yourself on the type of function and the number and type(s) of the parameter(s)

    Function convertBackToTime()

This function converts the time given in minutes to time in hours and minutes, e.g. 570 minutes is converted to 9h30. You have to decide the type of function and the number and type(s) of parameter(s).

Hint: Use the operators / and % to calculate the number of hours and minutes from the total number of minutes

     Function calcCharge()

This function calculates the amount due based on the parked time in hours and minutes. Again you have to decide yourself on the type of function and the number of type(s) of the parameter(s)

Run your program on the data below. The first two values in a row represent the hours and minutes of the entry time and the last two values represent the hours and minutes of the exit time.

Submit the printouts of the program and output together with the USB

9 30             13 23

8 00             12 59

10 12           13 13

10 00           12 12

7 01             17 14

-5 65           10 60

6 18             16 33

14 15           16 04

13 11           17 45

11 27           24 55

8 55             25 61

8 55             15 47