| | |
What does this mean?
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2004
Posts: 11
Reputation:
Solved Threads: 0
thanks for all the help that gave me help ;-)
the only question if i get the code of::: error C2447: missing function header (old-style formal list?) does that mean i missed a bracket, or was i suspposed to do something else i think i might of mixed up open and closeing brackets but i not the best with codeing just trying my luck and self teaching..
the only question if i get the code of::: error C2447: missing function header (old-style formal list?) does that mean i missed a bracket, or was i suspposed to do something else i think i might of mixed up open and closeing brackets but i not the best with codeing just trying my luck and self teaching..
•
•
Join Date: Sep 2004
Posts: 11
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by big146
I think what you want is somethng like this...(by the way I looked at your profile so i know you are not a kid working on homework).
C++ Syntax (Toggle Plain Text)
#include <iostream> using std::cout; using std::endl; using std::cin; using std::fixed; #include <iomanip> using std::setw; using std::setprecision; #include <cmath> double calculateCharges( double ); int main() { double hour; // hours parked for each car double currentCharge; // current parking charge double totalCharges = 0.0; // total charges double totalHours = 0.0; // total hours cout << "Enter the hours parked for three cars: "; for ( int i = 1; i <= 3; i++ ) { cin >> hour; totalHours += hour; if ( i == 1 ) { cout << setw( 5 ) << "Car" << setw( 15 ) << "Hours" << setw( 15 ) << "Charge\n"; } // end if totalCharges += ( currentCharge = calculateCharges( hour ) ); cout << fixed << setw( 3 ) << i << setw( 17 ) << setprecision( 1 ) << hour << setw( 15 ) << setprecision( 2 ) << currentCharge << "\n"; } // end for cout << setw( 7 ) << "TOTAL" << setw( 13 ) << setprecision( 1 ) << totalHours << setw( 15 ) << setprecision( 2 ) << totalCharges << endl; return 0; } // end main // calculate charges for hours parked double calculateCharges( double hours ) { double charge; if ( hours < 3.0 ) charge = 2.0; else if ( hours < 19.0 ) charge = 2.0 + .5 * ceil( hours - 3.0 ); else charge = 10.0; return charge; } // end function calculateCharges
thanks for the example code it helps me learn this hobby :cheesy:
•
•
Join Date: Sep 2004
Posts: 11
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by big buc's fan
question when i try to run you code how come it doesn't say on the screen so i came see what come out?
thanks for the example code it helps me learn this hobby :cheesy:
thanks again from a bad speller
•
•
•
•
Originally Posted by big buc's fan
sorry about the spell check i miss a couple of letters it should read " when i try to run your code how come it doesn't stay on the screen so i can see what the outcome is?"
thanks again from a bad speller
Dont forget to spread the reputation to those that deserve!
Just put a at the end of the code, exactly before command...
C++ Syntax (Toggle Plain Text)
cin.get()
C++ Syntax (Toggle Plain Text)
return 0
![]() |
Other Threads in the C++ Forum
- Previous Thread: C++ handling of strings in a boolean expression
- Next Thread: Giving me hadaches
Views: 5473 | Replies: 14
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll dynamiccharacterarray email encryption error file format forms fstream function functions game givemetehcodez graph homeworkhelp iamthwee ifstream input int java lib library lines list loop looping loops map math matrix memory newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search simple sort sorting spoonfeeding string strings struct temperature template templates text tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets





