Question

A parking garage has 5 customers daily. The garage charges a $5.00 minimum fee to park...

A parking garage has 5 customers daily. The garage charges a $5.00 minimum fee to park up to two hours. The garage charges an additional $1.00 per hour for each hour (or part of an hour) over two hours. The maximum charge for any given day is $12.00. All cars are gone by midnight. Write a program to calculate and print a summary of the charges for a day. For input the program will read the hours of usage for each of the 5 cars. The program will print the results in the form of a table in a neat format, as shown below.

Enter the hours parked for car 1: 1.5

Enter the hours parked for car 2: 4.1

Enter the hours parked for car 3: 12.0

Enter the hours parked for car 4: 9.3

Enter the hours parked for car 5: 0.5

Total Hours 27.4       

Total Charge $42.00

Use one decimal place for the hours parked, and 2 for the total charge. Name this program ParkingGarage.cpp

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Note: the calculation of the charge is a detail, and instead of giving $ 44.4 in question gives 42.0 $.

Solution:

file ParkingGarage.cpp

#include <stdio.h>
#include <stdlib.h>

int main(){
float garage_charge=5.0, garage_charge_additional=1.0, garage_charge_maximum=12.0; //variables
float cars[5], total_hours, total_charge;
  
total_hours = total_charge = 0.0; // initials values
  
// read data for cars
for (int i=0; i<5; i++){
while (true){
printf("Enter the hours parked for car %d: ",i+1);
scanf("%f", &cars[i]);
if (cars[i]>12.0)
printf("Enter value no more than 12 hours");
else
break;
}
}

for (int i=0; i<5; i++){
if (cars[i]<=2.0){ // if hours is <= 2.0 then the rate is $ 5.00
total_charge += garage_charge;
}else{ // but will be $ 5.00 more the calculation of the additional hour for each hour
total_charge += garage_charge + ((cars[i]-2.0)*garage_charge_additional);
}
  
total_hours += cars[i]; // calculate the total hours
}
  
// print results
printf("\n\nTotal Hours %.2f\n", total_hours);
printf("Total Charge $%.2f\n\n",total_charge);
  
system("pause");
return 0;
}

output:

D:Documents and Settings lpineronelEscritorio IPROGRAMACION ParkingGarage.exe Time remaining to comple Enter the hours parked


answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
A parking garage has 5 customers daily. The garage charges a $5.00 minimum fee to park...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment: My friend, Cary Parker, owns a small parking garage downtown. She wants you to write...

    Assignment: My friend, Cary Parker, owns a small parking garage downtown. She wants you to write a program to help her calculate the parking charge at the payment booth. The price to park in the lot is $5.50 per hour, plus city parking tax. However, partial hours (even one minute into an additional hour) are charged at the full hour’s rate. For example, if you park for exactly 60 minutes, or less, you will pay $5.50 plus tax, but if...

  • Write a program in C An international airport offers long term parking at the following rates:...

    Write a program in C An international airport offers long term parking at the following rates: First 60 minutes is free; 61-80 minutes $4; Each additional 20 minutes $2; And $18 max. per day (24 hours). Write a program longterm_parking.c that calculates and prints the charges for parking at the long term parking garage. 1. The user enters the number of total hours and minutes; the program prints the charge. 2. If the input is invalid, print a message and...

  • Objective: The objective of this lab is to get familiar with the syntax of the Java...

    Objective: The objective of this lab is to get familiar with the syntax of the Java programming language. This lab is designed to reinforce programming concepts. Instructions: Description of the Problem. 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...

  • This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to...

    This is a c++ program. Use the description from Parking Ticket Simulator (listed below) as a basis, where you need to create a Car class and Police Officer class, to create a new simulation. Write a simulation program (refer to the Bank Teller example listed below) that simulates cars entering a parking lot, paying for parking, and leaving the parking lot. The officer will randomly appear to survey the cars in the lot to ensure that no cars are parked...

  • please answer #5 The Stratton Township Park The Stratton Township Park is located on a piece...

    please answer #5 The Stratton Township Park The Stratton Township Park is located on a piece of property that contains two golf courses, a swimming pool, and 800 acres of woods and open spaces. Three years ago, the Stratton Parks Department (Stratton) carved out miles of trails to allow visitors to hike the property and enjoy nature. To make that experience more enjoyable for visitors and available to school groups, Stratton decided to offer guided tours that have proven popular....

  • I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if,...

    I need help in C++ . Project 3 – Parking Deck Ticketing System Objectives: Use if, switch, and loop statements to solve a problem. Use input and output statements to model a real world application Incorporate functions to divide the program into smaller segments Instructions: Your task is to write a program that simulates a parking meter within the parking deck. The program will start by reading in the time a car arrives in the parking deck. It will then...

  • Write a program to run the following methods in C#. 2) Write a method that takes...

    Write a program to run the following methods in C#. 2) Write a method that takes in a teacher’s last name and exam number via parameters. Ask the teacher (using her name) to tell you the highest score on that exam. Your question should look something like “Ms. Jones, what was the highest grade on test two?” Return the value of the highest grade to the calling method. 3) Write a function called MinOfThree that takes in three numbers and...

  • What rates should be charged? Downtown Parking Authority In January a meeting was held in the office of the mayor of Oa...

    What rates should be charged? Downtown Parking Authority In January a meeting was held in the office of the mayor of Oakmont to discuss a unicipal parking facility. The participants included the mayor, the traffic proposca the administrator of Oakmont's Downtown Parking Authority, the city planner, and the finance director. The purpose of the meeting was to consider a report Richard Stockton, executive assistant to the Parking Authority's administrator, concerning estimated costs and revenues for the proposed facility. Mr. Stockton's...

  • The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for...

    The electric company charges according to the following rate schedule: 9 cents per kilowatt-hour (kwh) for the first 300 kwh 8 cents per kwh for the next 300 kwh (up to 600 kwh) 6 cents per kwh for the next 400 kwh (up to 1000 kwh) 5 cents per kwh for all electricity used over 1000 kwh Write a program that would repeatedly read in a customer number (an integer) and the usage for that customer in kwh (an integer)....

  • What additional information, if any, should be obtained before making a final decision? Downtown Parking Authority In J...

    What additional information, if any, should be obtained before making a final decision? Downtown Parking Authority In January a meeting was held in the office of the mayor of Oakmont to discuss a unicipal parking facility. The participants included the mayor, the traffic proposca the administrator of Oakmont's Downtown Parking Authority, the city planner, and the finance director. The purpose of the meeting was to consider a report Richard Stockton, executive assistant to the Parking Authority's administrator, concerning estimated costs...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT