A program that would calculate and print the parking charges

Assignment Help Computer Engineering
Reference no: EM1331728

A parking garage charges a minimum fee of $2.00 to park for up to 3 hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of 3 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 3 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 neat tabular format, and should calculate and print the total of yesterday'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

1 1.5 2.00

2 4.0 2.50

3 24.0 10.00

Total 29.5 14.50

This is what I have so far please help because it will not work thanks

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <string>

using namespace std;

const int CARS = 3;
static int hours[CARS] = {0, 0, 0,};

void enterHoursParked()
{
for(int i=0;i<CARS;i++)
{
cout << "Enter the hours parked for each car"<< i;
cin >> hours[i];
}

}

float calculateCharges(int ilen)
{
float finalCharge;

if (ilen <= 3)
finalCharge = 2;
if (ilen >= 19)
finalCharge = 10;
if (ilen > 3)
finalCharge = 2 + (float)(ilen - 3) * .50;

return finalCharge;
}
void printCharges(int carno, int hours, float finalCharge)
{
if(carno == 0)
cout << "Car Hours Chargen";
else
cout << (carno)<<" "<< hours<<" "<< finalCharge<<"n";

}

int main()
{

cout << "Welcome!" << endl;
enterHoursParked();

for (int i = 0; i <= CARS; i++)
{
float finalCharge = calculateCharges(hours[i]);
printCharges(i,hours[i],finalCharge );

}

int l;
cin>>l;

return 0;
}

Reference no: EM1331728

Questions Cloud

Make a c++ program containing a class fraction : construct a C++ program containing a class Fraction. The class data should have two variables numerator and denominator, both of type integer, to represent the fraction numerator/denominator.
Environmental scanning strategy formulation : The assignment is a paper pertaining to Microsoft's Go to Market Strategy for Azure in India. It must discuss Microsoft in India, Information Technology in India pertaining to Mcrosoft Azure and the impact of cloud computing.
Describe the problem or protect the situation from occurring : Describe the problem or protect the situation from occurring
Cultural diversity in organization impact company-s culture : List the important factors that a manager should keep in mind if his or her organization has a diverse workforce. How does cultural diversity in an organization impact the company's culture?
A program that would calculate and print the parking charges : A parking garage charges a atleast fee of $2.00 to park for up to 3 hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of 3 hours.
Electronic monitoring of employee behavior : Electronic Monitoring of Employee Behavior - Show whether managers are justified in monitoring employees to this degree.
Case law and rule of law : Client recently bought a toaster at a local flea market. The market is open year-round, Friday through Sunday.Client bought the same toaster at a garage sale.
Compare and contrast the synergy approach : Compare and contrast the synergy approach and the parenting/patching approach - pros and cons to each?
Does your company use any hr practices : Human Resource Management - training and development or labor-employee relations

Reviews

Write a Review

Computer Engineering Questions & Answers

  Classify the use and location of firewalls

Classify the use and location of Firewalls Categorize the use and location of IPS or IDS where necessary.

  In short define asynchronous communications

express packet switching and the benefits of packet switching. What are examples of packet switching networks.

  Find out the model number of the item

Find out the maker(s) of the PC(s) with the fastest processor among all those PCs that have the smallest amount of RAM.

  Creating a new domain tree root checkbox

In case, I select the “Create a new domain tree root checkbox” in place of the “Create a new child domain checkbox”, how would configuration of the forest be different?

  Avoiding breaches in health care information system

Analyze the financial and privacy impacts of the breaches to health care information systems and make at least two recommendations in order to prevent such breaches in future.

  Write an essay on wifi performance

Write an essay on WiFi performance

  Companies still fail in their use of information technology

Why do big companies still fail in their use of information technology? What should they be doing differently.

  Data planning and enterprise modelling

Describe the major differences between two approaches for data planning and enterprise modelling and examine the integration? Why do these two methodologies usually produce several results?

  New network equipment based on the above description

A fast and reliable PLC communications network is important to ensure that production remains uninterrupted. If equipment failure occurs, time is spent on troubleshooting and repair.

  Discuss software testing as a career path in brief

discuss software testing as a career path in brief. The techniques for solving linear equations and linear inequalities are similar, yet different. Explain and give an example of both a linear equation and a linear inequality that demonstrates this..

  Encode the same sequence using run-length

Encode the following bit sequence using run-length encoding with 4-bit codes.

  Developing the java servlet

Provide the Java servlet which utilizes the doGet in order to return the markup document which offers your name.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd