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

  What is online analytical processing system

What is online analytical processing system

  An approximation to a zero of a continuous function

provide a pseudocode for the bisection method algorithm Bise(f(x),a,b,error) for finding an approximation to a zero of a continuous function f(x) in the interval [a, b] accurate to within error.

  Write an essay on wifi performance

Write an essay on WiFi performance

  Creating a program that creates a single tips object

Creating a program that creates a single Tips object

  What required to happen in order for the database

If the computers of organization are to old, the database management system might not be installed in the organization and will not run properly or sometimes not at all. This information is good to remember as planning a particular database implem..

  Explain the effect of data rates on a network

discuss the effect of data rates on a network?

  How to use the same naming conventions

how to use the same naming conventions and that their programs work together even though they are created independently.

  What profit do you see with partitioned view

Explain your idea for a database along with your thoughts for a partitioned view. 1. How will you use this partitioned view?

  What are race situations difficult to debug

assume the legislature in your state is debating the adoption of UCITA and you have been known as an expert witness. What are the three most important ideas you want your legislators to get from the testimony.

  What types of relationships that exist between tables

What are the differences between relational database models and object-oriented database models? express at least 2 differences at length.

  Handling the error

Alter your program so that it consider the arguments provided at the command line are integers. If there are no arguments, print the message.

  Program for dissimilar values for real numbers

Program for dissimilar values for real numbers

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