# what's wrong with my pointer?

This is a discussion on what's wrong with my pointer? within the C++ Programming forums, part of the General Programming Boards category; /* Calculate the total charges and the total hours for the parking garage. */ #include <iostream> using std::cout; using std::cin; ...

1. ## what's wrong with my pointer?

/* Calculate the total charges and the total hours for the
parking garage. */

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

#include <iomanip>

using std::setw;

double calculateCharges ( double );

int main ()
{
double a;
double b;
double c;
double totalcharges;

cout << "Enter the number of hours for CAR 1:";
cin >> a;

cout << "Enter the number of hours for CAR 2:";
cin >> b;

cout << "Enter the number of hours for CAR 3:";
cin >> c;

cout << "CAR:" << setw( 10 ) << "HOURS:" << setw( 15 )
<< "CHARGES:\n";

cout << " 1 " << setw( 10 ) << a << setw( 10 )
<< calculateCharges( a ) << "\n";
totalcharges += calculateCharges( a );

cout << " 2 " << setw( 10 ) << b << setw( 10 )
<< calculateCharges( b ) << "\n";
totalcharges += calculateCharges( b );

cout << " 3 " << setw( 10 ) << c << setw( 10 )
<< calculateCharges( c ) << "\n";
totalcharges += calculateCharges( c );

cout << "TOTALS:" << setw( 6 ) << a + b + c << setw( 10 )
<< totalcharges << endl;

return 0;
}

double calculateCharges ( double hours )
{
double charges = 0.0;
couble *chargesPtr;
*chargesPtr = &charges;

if ( hours <= 3)
charges = 2.00;
else
if ( hours >= 16 )
charges = 10.00;
else
charges = 2.00 + ( ( hours - 3 ) * 0.50 );

return *chargesPtr;
}

2. *chargesPtr = &charges;
should change to :
*chargesPtr = charges;

3. Why do you want to use a pointer?

4. i think its the couble *chargesPtr; ///i think
//u meant double!?