A parking garage charges a 2.00 minimum fee to park for up to three hours. The g
ID: 3628850 • Letter: A
Question
A parking garage charges a 2.00 minimum fee to park for up to three hours. The garage charges an additional .5 per hour for each hour or part of 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 application 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 application should display the charge for the current customer and should calculate and display the running total of yesterdayExplanation / Answer
using System; public class garage { public static void Main(string[] args) { double car = 0; double grandTotal = 0; double car1c=0; Console.WriteLine("Please input the amount of hours that your car was parked."); car=Convert.ToInt32(Console.ReadLine()); car1c=calculateCharges(car); Console.WriteLine("The charges are {0}", car1c); grandTotal=grandTotal + car1c; Console.WriteLine("Running total: {0}", grandTotal); // return 0; } public static double calculateCharges(double parkTime) { double fee =2.00; if (parkTime>3.0) fee=(fee-2.00+parkTime)*.50; else if (parkTime >=24.0) fee=10.00; return fee; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.