Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A parking garage charges a $2.00 minimum fee to park for up to three hours. The

ID: 3548732 • Letter: A

Question

A parking garage charges a $2.00 minimum fee to park for up to three

hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of 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 an app that calculates and displays the parking charges for

each customer who parked in the garage yesterday. You should enter the hours parked for each customer.

The app should display the charge for the current customer and should calculate and display

the running total of yesterday

Explanation / Answer

using System.IO;
using System;

public class ParkingFee
{
    public static double CalculateCharges(int no_of_hours)
    {
    double charge = 2.0;
    if(no_of_hours<=3)
    charge = 2.0;
    else if(no_of_hours>3)
    {
    charge = 2.0 + (no_of_hours-3)*0.5;
    }
    if(charge>10)
    charge = 10;
    return charge;
    }
    public static void Main()
    {
    int no_of_customers;
    Console.WriteLine("Enter no of Customers Yesterday :");
    no_of_customers = int.Parse(Console.ReadLine());
    int[] customer_array = new int[no_of_customers];
    for(int i=0; i<no_of_customers; i++)
    {
    Console.WriteLine("How Many Hours Customer" + (i+1) + " Parked Yesterday :");
    customer_array[i] = int.Parse(Console.ReadLine());
    }
    for(int i=0; i<no_of_customers; i++)
    {
    Console.WriteLine("Customer " + (i+1) + " Parking Fee Given by : " + CalculateCharges(customer_array[i]));
    }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote