Code:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include <iomanip>
using std::setprecision;
using std::setiosflags;
using std::setw;
double calculateCharges ( double ); //function prototype
int main()
{
double hr1, //first hour
hr2, //second hour
hr3, //third hour
ttlhr, //Total hours
cr1, //First charge
cr2, //second charge
cr3, //third charge
ttlcr; //Total charge
cout << "Enter 3 hours: " ;
cin >> hr1 >> hr2 >> hr3;
cr1 = calculateCharges(hr1);
cr2 = calculateCharges(hr2);
cr3 = calculateCharges(hr3);
ttlcr = cr1 + cr2 + cr3;
ttlhr = hr1 + hr2 + hr3;
cout << "Car" << setw( 10 ) << "Hours" << setw( 10 ) << "Charge"
<< "\n 1" << setw( 10 ) << hr1 << setw( 10 ) << cr1
<< "\n 2" << setw( 10 ) << hr2 << setw( 10 ) << cr2
<< "\n 3" << setw( 10 ) << hr3 << setw( 10 ) << cr3
<< "\nTotal" << setw( 10 ) << ttlhr << setw( 10 ) << ttlcr;
return 0;
}
//function definition
double calculateCharges ( int hours )
{
double crg = 0;
if ( hours <= 3 ){
crg = 2.0;
}
if ((hours > 3.0) && (hours < 24.0)) {
crg = ( ( hours - 3.0 ) * .5 ) + 2.0;
}
if ( hours == 24.0 )
crg = 10.0;
return crg;
}
2 errors-
cred.obj : error LNK2001: unresolved external symbol "double __cdecl calculateCharges(double)" (?calculateCharges@@YANN@Z)
Debug/cred.exe : fatal error LNK1120: 1 unresolved externals
UPDATE: Nevermind i found my problem
double calculateCharges ( int hours ) should be double hours not int