Question
Here I have my code, the program needs to track and display the total revenue of all the customers tickets that are entered per program
Here I have my code, the program needs to 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 and the total number of customers that used a coupon. The revenue and the coupon are not working. Please help!
package PrattParkingGarage;
// package lab4;
import java.util.Scanner;
// 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("");
double totalRevenue = 0.00;
double totalTax = 0.00;
double totalTip = 0.00;
int totalCouponsUsed = 0;
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;
totalRevenue = totalRevenue + flatFee;
totalDueFromCust = flatFee;
}
if (rateCode == 'M')
{
monthFee = 90.00;
totalDueFromCust = monthFee;
// monthly fee is deferred
totalDueFromCust = 0;
}
System.out.println("tip amount");
tip = sc.nextDouble();
totalTip=totalTip+tip;
System.out.printf("tip: $%.2f ", tip);
totalDueFromCust += tip;
System.out.printf("flat tax: $%.2f ", flatTax);
totalDueFromCust += flatTax;
totalTax = totalTax + flatTax;
System.out.println("special event(Y or N)?");
specEvent = sc.next().charAt(0);
if(specEvent == 'Y') {
EXTRA_CHARGE = 10;
totalRevenue = totalRevenue + EXTRA_CHARGE;
}
totalDueFromCust += EXTRA_CHARGE;
totalRevenue = totalDueFromCust + EXTRA_CHARGE;
System.out.println("coupon amount");
coupon = sc.nextDouble();
totalDueFromCust -= coupon;
System.out.printf("total charge: $%.2f ", totalDueFromCust);
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
// i.e. prior to servicing the next customer
// by assigning a zero to the appropriate variables
totalDueFromCust =0;
ticketNum =0;
timeIn=0;
timeOut =0;
tip = 0;
coupon =0;
amountTendered =0;
changeDue=0;
flatFee=0;
monthFee=0;
EXTRA_CHARGE=0;
}
System.out.printf("The total revenue is $%.2f ", totalRevenue);
System.out.printf("Total tax: $%.2f ", totalTax);
System.out.printf("Total tip: $%.2f ", totalTip);
System.out.println("***************************");
}// end main()
}// end class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started