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

  Calculates the average of three test scores

Write a program that calculates the average of three test scores. The program should contain three value-returning functions: main, getTestScore, and calcAverage

  Write a set of nested loops that display 10 rows

Write a set of nested loops that display 10 rows of # characters. There should be 15 # characters in each row.

  Calculate the integer square root by calculating

Calculate the integer square root by calculating

  Write a function to print the data of a student

Write a function to print names of all students who joined in a particular year. Write a function to print the data of a student whose roll number is given.

  Calculate the total expences

Trying to fugure out how to enter a formula in a cell(d10) that multiplies 30 by the value in another cell (c27), then make the other cell (c27) an absolute cell reference in the formula. Copy the formula to cells d11:d13, and then calculate the t..

  Modify the program in 6a so that, in addition to the cents

Modify the program in 6a so that, in addition to the cents, the user enters the denomination of the coin to which to convert the pennies, such as 5 for nickles or 25 for quarters.

  Assume we have an array named $students

Assume we have an array named $students. Each entry in the array contains a student's full name (e.g. "Jane Smith"). Write the PHP code needed to display all students (in the array) whose first name starts with the letter "J".

  Define a structure to store marks of a student

Define a structure to store roll no, name and marks of a student - using the structure of Q2. a), above write a 'C' program to create a file "student.dat". There must be one record for every student in the file.

  Implement a class that supports an extendable variant

In this exercise you will practice basic C++ class construction, and memory allocation and deallocation. You are asked to implement a class that supports an extendable variant of a sparse matrix (look it up). A matrix is a two-dimensional array

  Would this code sequence compile? explain.

Using pseudocode or C++, write the statements to enter an integer number, compute the number raised to power 5 and output the result

  Make an explicit statement of the invariant of the set class

Prepare a new container class called ser, which is similar to a bag, except that a set can contain only one copy of any given item, you'll need to change the interface a bit.

  To use a sentinel loop so once the value of -99 i

modify this program to use a sentinal loop so once the value of -99 is entered after getting the pay and hours the program should end.

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