943,522 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 6514
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Sep 8th, 2004
0

Re: What does this mean?

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..
Reputation Points: 13
Solved Threads: 0
Newbie Poster
big buc's fan is offline Offline
11 posts
since Sep 2004
Sep 8th, 2004
0

Re: What does this mean?

Quote 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)
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::endl;
  5. using std::cin;
  6. using std::fixed;
  7.  
  8. #include <iomanip>
  9.  
  10. using std::setw;
  11. using std::setprecision;
  12.  
  13. #include <cmath>
  14.  
  15. double calculateCharges( double );
  16.  
  17. int main()
  18. {
  19. double hour; // hours parked for each car
  20. double currentCharge; // current parking charge
  21. double totalCharges = 0.0; // total charges
  22. double totalHours = 0.0; // total hours
  23.  
  24. cout << "Enter the hours parked for three cars: ";
  25.  
  26. for ( int i = 1; i <= 3; i++ ) {
  27. cin >> hour;
  28. totalHours += hour;
  29.  
  30. if ( i == 1 ) {
  31. cout << setw( 5 ) << "Car" << setw( 15 ) << "Hours"
  32. << setw( 15 ) << "Charge\n";
  33.  
  34. } // end if
  35.  
  36. totalCharges += ( currentCharge =
  37. calculateCharges( hour ) );
  38.  
  39. cout << fixed << setw( 3 ) << i << setw( 17 )
  40. << setprecision( 1 ) << hour
  41. << setw( 15 ) << setprecision( 2 )
  42. << currentCharge << "\n";
  43.  
  44. } // end for
  45.  
  46. cout << setw( 7 ) << "TOTAL" << setw( 13 ) << setprecision( 1 )
  47. << totalHours << setw( 15 ) << setprecision( 2 )
  48. << totalCharges << endl;
  49.  
  50. return 0;
  51.  
  52. } // end main
  53.  
  54. // calculate charges for hours parked
  55. double calculateCharges( double hours )
  56. {
  57. double charge;
  58.  
  59. if ( hours < 3.0 )
  60. charge = 2.0;
  61. else if ( hours < 19.0 )
  62. charge = 2.0 + .5 * ceil( hours - 3.0 );
  63. else
  64. charge = 10.0;
  65.  
  66. return charge;
  67.  
  68. } // end function calculateCharges
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:
Reputation Points: 13
Solved Threads: 0
Newbie Poster
big buc's fan is offline Offline
11 posts
since Sep 2004
Sep 8th, 2004
0

Re: What does this mean?

Quote 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:
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
Reputation Points: 13
Solved Threads: 0
Newbie Poster
big buc's fan is offline Offline
11 posts
since Sep 2004
Sep 8th, 2004
1

Re: What does this mean?

Quote 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
open up dos and navigate to the program and run it, then it will stay on the screen. there is also a fix for this too, that will wait for one last piece of input for the user before it closes. but i dont remember the syntax or the command.
Reputation Points: 152
Solved Threads: 39
Master Poster
Killer_Typo is offline Offline
778 posts
since Apr 2004
Sep 10th, 2004
1

Re: What does this mean?

Just put a
C++ Syntax (Toggle Plain Text)
  1. cin.get()
at the end of the code, exactly before
C++ Syntax (Toggle Plain Text)
  1. return 0
command...
Reputation Points: 17
Solved Threads: 9
Posting Whiz in Training
frrossk is offline Offline
220 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ handling of strings in a boolean expression
Next Thread in C++ Forum Timeline: Giving me hadaches





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC