Billing charges program

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 24hr period is $10.00. Assume that no cars parked for longer than 24hrs at a time. Write a program that will calculate and print the parking charges for each of three customers who parked cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the result in a neat tabular format and should calculate and print the total of yesterday’s receipts. Now this is what the output should look like:

Car Hours Charges
1 1.5 2.00
2 4.00 2.50
3 24.00 10.00

So far these are the issues I am facing:
::My output is nowhere anything like the one above (copy and paste the code to see what I mean).
::I can’t seem to process floating point values.
::Variable nTotalCharges is giving me bogus numbers.
::In general I can’t seem to organize the code to achieve what I want.

This here is my code so far:
#include <iostream>
#include <iomanip>

using namespace std;
void calculateCharges(int);

int main()
{
//accept inputs from the user in terms of hours
int nInputHours;
cout << "Enter the number of hours parked (-1 to end) : ";
cin >> nInputHours;

//calling function calculate charges
calculateCharges(nInputHours);
return 0;
}

//function definition
void calculateCharges(int nHoursUsed)
{
double dNormalCharge = 2; //amount charged for cars parked below or equall to 3hrs
double dExtraCharge = 0.50; //amount charged for every hour above 3hrs
const int nMaxHour = 24; //the maximum hour permitted to park a car
const int nNormalHour = 3; //the hours considered to be normal without attracting extra cost
double dMaxCharge = 10; //amount charged for parking up to 24hrs
int nTotalHours = 0; //holds the total of hours for a complete business day
double nTotalCharges = 0; //holds the total charge for a complete business day


//runs a comparism check for the inputed hours used by the customer
int counter = 1;
while (nHoursUsed != -1)
{
if (nHoursUsed >= 0 && nHoursUsed <= nNormalHour)
cout << setw(3) << counter << setw(8) << nHoursUsed << setw(11) << setprecision(2)
<< setiosflags(ios::fixed | ios::showpoint) << dNormalCharge << endl;
if (nHoursUsed > nNormalHour && nHoursUsed < nMaxHour)
cout << setw(3) << counter << setw(8) << nHoursUsed << setw(11) << setprecision(2)
<< setiosflags(ios::fixed | ios::showpoint) << ((nHoursUsed - nNormalHour) * dExtraCharge) + dNormalCharge << endl;
if (nHoursUsed == nMaxHour)
cout << setw(3) << counter << setw(8) << nHoursUsed << setw(11) << setprecision(2)
<< setiosflags(ios::fixed | ios::showpoint) << dMaxCharge << endl;
++counter;
nTotalHours += nHoursUsed;
nTotalCharges += dNormalCharge + (((nHoursUsed - nNormalHour) * dExtraCharge) + dNormalCharge) + dMaxCharge;
//...
cout << "Enter the number of hours parked (-1 to end) : ";
cin >> nHoursUsed;

}

//terminate the program and print the result
if (nHoursUsed == -1){
cout << "Car" << setw(8) << "Hours" << setw(11) << "charge" <<endl;
cout << "Total : " << setw(3) << nTotalHours << setw(11) << nTotalCharges << endl;
}else{
//...
cout << "\n\nProgram Aborted..." << endl;
}

}




Plus I am to write this program within the confines of the following topics:
Control structures and functions

And please if I don’t reply to any of your contributions early enough it is not that I am not taking learning serious enough. It is just that I may not have been able to access the internet as yet or i am taking my time to assimilate your contributions.
Thanks for your time and contributions.
Topic archived. No new replies allowed.