Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

5 . 9 ( Parking Charges ) A parking garage charges a $ 2 . 0 0 minimum fee to park for up to three

5.9(Parking Charges) A parking garage charges a $2.00 minimum fee to park for up to three hours and an additional $0.50 per hour for each hour or part thereof 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 calculates and prints the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a tabular format, and should calculate and print the total of yester-day's receipts. The program should use the function calculateCharges to determine the charge for each customer. Your outputs should appear in the following format:
Car Hours Charge
11.52.00
24.02.50
324.010.00
Total 29.514.50
Pseudo code. Remember the Input, process, output model. Look at what the input should be, what the process is, and what the output should be. Use the code examples in the book and our week 1 lab to understand how to code the input, process, and output. First go into the problem statements above and highlight what needs to be done. Remember chapter 3, the decomposition and using stepwise analysis when developing an algorithm/pseudo code. You will create one function in this program.
Pseudo code:
Create function prototype for calculating charges (hint: pass in hours)
Prompt user to "Enter the hours parked for 3 cars: "
Declare need variables (hint: I declared and initialized 3 variables!)
Set up for loop
Declare a variable to hold hours
Accept input for hours entered by user
Add hours entered to total hours accumulator variable
Test if first time in the loop to print table column headers (Cars Hours Charge)
Calculate current car's charge and update total by calling function
Add current charge to total charge accumulator variable
Display data for current car (car number, current hours, current charges)
End for loop
Display row data for totals
End of main
Create function calculateCharges to return charge according to number of hours
Create pseudo code here. Be sure to submit pseudo code with your submission
End program
Program Code:
/*
COSC1420 Lab05: Target Heart-Rate Calculator
Programmer: Enter Student Name
Date: Enter date program written
Place pseudo code here
*/
#include // standard input and output library
#include // will use math library functions
Function prototype goes here
int main(void)// main function code block
{
ENTER CODE HINT: Use the pseudo code to help document your program.
return 0;
}// end main function
Function definition goes here
End program
Test Data:
Car Hours Charge
11.52.00
24.02.50
324.010.00
Total 29.514.50
SAMPLE RUN :
Enter the hours parked for 3 cars:
Enter the hours parked for 1 car : 1.5
Car Hours Charge
11.52.0
Enter the hours parked for 2 car : 4.0
Car Hours Charge
24.02.50
Enter the hours parked for 3 car : 24.0
Car Hours Charge
324.010.0
Total 29.514.50
.....Program finished with exit code 0
Press ENTER to exit console.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database And Information Systems Research Advances

Authors: Azer Bestavros ,Victor Fay-Wolfe

1st Edition

1461377803, 978-1461377801

More Books

Students also viewed these Databases questions