Im a newbie of course and im taking a class to learning c++. We are in the functions chapter and this is my code which i have made so far.... i have no idea where to go what to do etc.
btw, I am doing problem 3.12
[Source Code]
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
This is the original problem out of the book:Code:#include <iomanip> using std::setprecision; using std::setiosflags; using std::setw; int calculateCharges ( int ) //function prototype int main() { int 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; ttlhr = hr1 + hr2 + hr3; cout << "Car" << setw( 10 ) << "Hours" << setw( 10 ) << "Charge" << "\n 1" << setw( 10 ) << hr1 << setw( 10 ) << << "\n 2" << setw( 10 ) << hr2 << setw( 10 ) << << "\n 3" << setw( 10 ) << hr3 << setw( 10 ) << << "\nTotal" << setw( 10 ) << ttlhr << setw( 10 ) << ttlcr; return 0; } //function definition int calculateCharges ( int hours ) { int crg = 0; if ( hours <= 3 ) crg = 2; if ( hours > 3 ) crg = ( ( hours - 3 ) * .5 ) + 2 if ( hours == 24 ) crg = 10; return crg; }
http://members.cox.net/eazhar/prob3.jpg



LinkBack URL
About LinkBacks


