Question

In: Computer Science

Write a Java Program.A parking garage charges a $3.00 minimum fee to park for up to...

Write a Java Program.A parking garage charges a $3.00 minimum fee to park for up to three hours. The garage charges an additional $0.75 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $12.00 per day. Write an application that calculates and displays the parking charges for all customers who parked in the garage yesterday. You should enter the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the grand total of yesterday’s receipts. Use a sentinel controlled loop.

Solutions

Expert Solution

ParkingChargesBill.java

import java.util.Scanner;

public class ParkingChargesBill {

   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       System.out
               .println("Enter the hours parked for customer (-1 to quit): ");
       int hours = scan.nextInt();
       double totalCharges = 0;
       while (hours != -1) {
           double charges = 0;
           if (hours > 24) {
               charges = 12 * hours / 24;
               hours = hours % 24;
           }
           if (hours > 3) {
               charges = charges + 3;
               hours = hours - 3;
               charges = charges + 0.75 * hours;
           } else {
               charges = charges + 3;
           }
           System.out.println("Parking charges for current customer is "
                   + charges);
           totalCharges = totalCharges + charges;
           System.out
                   .println("Enter the hours parked for customer (-1 to quit): ");
           hours = scan.nextInt();

       }
       System.out.println("Total Parking chrages for all customers is "
               + totalCharges);
   }

}

Output:

Enter the hours parked for customer (-1 to quit):
25
Parking charges for current customer is 15.0
Enter the hours parked for customer (-1 to quit):
12
Parking charges for current customer is 9.75
Enter the hours parked for customer (-1 to quit):
2
Parking charges for current customer is 3.0
Enter the hours parked for customer (-1 to quit):
5
Parking charges for current customer is 4.5
Enter the hours parked for customer (-1 to quit):
-1
Total Parking chrages for all customers is 32.25


Related Solutions

A parking garage charges R7.50 minimum fee to park for up to three and half hours....
A parking garage charges R7.50 minimum fee to park for up to three and half hours. The garage charges an additional R1.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24- hour period is R25.72. Write a program that calculates and prints the parking charges for each of three customers who parked their cars in this garage at some time. You should enter the hours parked for each customer....
Use CPP 1) Parking charge application: A parking garage charges a $20.00 minimum fee to park...
Use CPP 1) Parking charge application: A parking garage charges a $20.00 minimum fee to park for up to 3 hours. The garage charges an additional $5.00 per hour for hour or part thereof in excess of 3 hours. The maximum charge for any given 24-hour period is $50.00. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and prints the parking charge for each of 3 customers who parked their...
C program and pseudocode for this problem. A parking garage charges a $2.00 minimum fee to...
C program and pseudocode for this problem. A parking garage charges a $2.00 minimum fee to park for up to three hours and additional $0.50 per hour over three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter...
Loaded-up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy...
Loaded-up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.10%. Assume the ratio of return on both funds' portfolios (before any fees) is 5% per year. How much will an investment of $100 in each fund grow after 1 year? How much will an investment of $100 in each fund grow after 2 years? loaded-up fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.70%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.70%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.30%. Assume the rate of return on both funds’ portfolios (before any fees) is 7% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.25%. Assume the rate of return on both funds’ portfolios (before any fees) is 6% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Loaded up...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.80%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.80%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.20%. Assume the rate of return on both funds’ portfolios (before any fees) is 10% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.) Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.90%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.10%. Assume the rate of return on both funds’ portfolios (before any fees) is 5% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.)   Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.75%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.25%. Assume the rate of return on both funds’ portfolios (before any fees) is 7% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.)   Loaded-Up Fund...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.65%. Economy...
Loaded-Up Fund charges a 12b-1 fee of 1% and maintains an expense ratio of 0.65%. Economy Fund charges a front-end load of 2%, but has no 12b-1 fee and an expense ratio of 0.35%. Assume the rate of return on both funds’ portfolios (before any fees) is 6% per year. a. How much will an investment of $100 in each fund grow to after 1 year? (Do not round intermediate calculations. Round your answers to 2 decimal places.)   Loaded-Up Fund...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT