Function calculatecharges to determine the charge

Assignment Help C/C++ Programming
Reference no: EM13937635

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: EM13937635

Questions Cloud

What is the payback period for this project : McGilla Golf has decided to sell a new line of golf clubs. The length of this project is seven years. The company has spent $1915230 on research and development for the new clubs. The plant and equipment required will cost $28720691 and will be depre..
Find simpronius maximum willingness to pay for insurance : Find Simpronius's maximum willingness to pay for insurance (maximum insurance premium that insurance company can charge and Semronious will be willing to pay for it). Assume he will buy full coverage.
What is the aftertax cost of debt if the tax rate : Decline, Inc. is trying to determine its cost of debt. The firm has a debt issue outstanding with 15 years to maturity that is quoted at 102.7 percent of face value. The issue makes semiannual payments and has an embedded cost of 9 percent annually. ..
Difference in increased assets-seasonal asset requirements : Assuming increasing sales growth, what is the difference between a permanent need for increased assets and seasonal asset requirements? Explain the costs and benefits of the following policies: Restrictive, Compromise and Flexible financing policies...
Function calculatecharges to determine the charge : The program should use the function calculateCharges to determine the charge for each customer. Your outputs should appear in the following format:
Discuss the differences between instruction and training : After selecting an organization, write a paper with the following: In the introduction to your paper, discuss the differences between instruction and training. Explain and describe the type of training program your organization intends to develop
Analyze the company modes of foreign involvement : Compare and contrast the company's global sourcing of equity and debt financing strategies with the strategies utilized by its nearest competitor. Evaluate the company's strategy toward international diversification by illustrating both the ben..
What is the par value of the companys common stock : What is the par value of the company's common stock? Did the company issue any new shares during the fiscal year ended December 31, 2006?
The general journal entry to record this transaction : On September 1, Ziegler Corporation had 71,000 shares of $5 par value common stock, and $213,000 of retained earnings. On that date, when the market price of the stock is $15 per share, the corporation issues a 2-for-1 stock split. The general journa..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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