Question: Figure 1 Source Code for the Parking Garage Program // package lab4; import java.util.Scanner; // Sammy Student, Programmer public class PrattParkingGarage { static Scanner sc

Figure 1 Source Code for the Parking Garage Program

// package lab4;

import java.util.Scanner;

// Sammy Student, Programmer

public class PrattParkingGarage

{

static Scanner sc = new Scanner(System.in);

public static void main(String args[])

{

// the local variables declared and initialized

char answer = 'Y', specEvent = 'N', rateCode = '\0';

int ticketNum = 0;

int timeIn = 0, timeOut = 0, timeDiff = 0;

double amountTendered = 0.0, changeDue = 0.0;

double flatFee = 0.0, monthFee = 0.0;

double EXTRA_CHARGE = 0.0;

double coupon = 0.0, tip = 0.0;

double flatTax = 3.00, totalDueFromCust = 0.0;

System.out.println("");

System.out.println("");

System.out.println("***************************");

System.out.println("----Pratt Parking Garage---");

System.out.println("***************************");

System.out.println("");

System.out.println("");

PROJECT Parking Garage - Repetition Structures

Figure 1 Source Code for the Parking Garage Program ( continued )

while(answer == 'Y' || answer == 'y')

{

System.out.println("--------- M E N U ---------");

System.out.println("data entry process: enter each of these");

System.out.println("customer ticket number ->");

ticketNum = sc.nextInt();

System.out.println("ticket number " + (ticketNum));

System.out.println("time in (military)");

timeIn = sc.nextInt();

System.out.println("time out (military)");

timeOut = sc.nextInt();

timeDiff = timeOut - timeIn;

System.out.println("time difference " + (timeDiff));

System.out.println("rate code: (F or M)");

rateCode = sc.next().charAt(0);

System.out.println("rate code: " + rateCode);

if (rateCode == 'F')

{

flatFee = 10.00;

totalDueFromCust = flatFee;

}

if (rateCode == 'M')

{

monthFee = 90.00;

totalDueFromCust = monthFee;

// monthly fee is deferred

totalDueFromCust = 0;

}

System.out.println("tip amount");

tip = sc.nextDouble();

System.out.printf("tip: $%.2f ", tip);

totalDueFromCust += tip;

System.out.printf("flat tax: $%.2f ", flatTax);

totalDueFromCust += flatTax;

System.out.println("special event(Y or N)?");

specEvent = sc.next().charAt(0);

if(specEvent == 'Y') EXTRA_CHARGE = 10;

totalDueFromCust += EXTRA_CHARGE;

System.out.println("coupon amount");

coupon = sc.nextDouble();

totalDueFromCust -= coupon;

System.out.printf("total charge: $%.2f ", totalDueFromCust);

PROJECT Parking Garage - Repetition Structures

Figure 1 Source Code for the Parking Garage Program ( continued )

System.out.println("amount tendered from customer");

amountTendered = sc.nextDouble();

changeDue = amountTendered - totalDueFromCust;

System.out.printf("change: $%.2f ", changeDue);

System.out.println("***************************");

System.out.println("run again(Y or N)?");

answer = sc.next().charAt(0);

// reset all pertinent variables before the next loop ( customer )

// by assigning a zero to the appropriate variables

}

System.out.println("***************************");

}// end main()

}// end class

Review the Starter Code Program Statements

The initial starter code computes the fee to be paid by customers of the parking garage. Some of the customers of the parking garage pay a one - time flat fee and some customers are on a monthly rate. All customers are clocked for entry

( check - in ) and exit ( check - out ) times, whereby the time difference is provided by your program. Flat fee ( code F ) customers pay a one - time charge each time they use the parking garage, regardless of the number of hours they use the garage in any given day. Monthly fee ( code M ) customers pay a separately billed one - time monthly charge and are not charged each time they use the parking garage, but are liable for any tax or tip incurred on any given parking lot use.

All customers can leave a tip for their parking attendant and have the tip included in their total parking fee.

Special events, for nearby theater and entertainment venues, incur an extra charge for each customer, except those that pay a monthly fee. A coupon can be used for a fee discount for flat fee patrons. Coupons are not valid for monthly fee patrons.

A flat tax is added to every customer ticket charge, regardless of their customer category.

Customers make a payment based on their parking charge and your program will compute any change tendered by the garage cashiers.

Modify the existing program code to conform to all the requirements in STEP 3 and supplement your existing code to perform all of the following tasks:

Include accumulating variables that will track and display the total revenue of

all the customers tickets that are entered per program run, as well as the total tax and tip amounts.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!