What does this mean?

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2004
Posts: 11
Reputation: big buc's fan is an unknown quantity at this point 
Solved Threads: 0
big buc's fan big buc's fan is offline Offline
Newbie Poster

Re: What does this mean?

 
0
  #11
Sep 8th, 2004
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..
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 11
Reputation: big buc's fan is an unknown quantity at this point 
Solved Threads: 0
big buc's fan big buc's fan is offline Offline
Newbie Poster

Re: What does this mean?

 
0
  #12
Sep 8th, 2004
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).

  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:
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 11
Reputation: big buc's fan is an unknown quantity at this point 
Solved Threads: 0
big buc's fan big buc's fan is offline Offline
Newbie Poster

Re: What does this mean?

 
0
  #13
Sep 8th, 2004
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 759
Reputation: Killer_Typo will become famous soon enough Killer_Typo will become famous soon enough 
Solved Threads: 35
Killer_Typo's Avatar
Killer_Typo Killer_Typo is offline Offline
Master Poster

Re: What does this mean?

 
1
  #14
Sep 8th, 2004
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.
Dont forget to spread the reputation to those that deserve!
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 220
Reputation: frrossk is an unknown quantity at this point 
Solved Threads: 9
frrossk's Avatar
frrossk frrossk is offline Offline
Posting Whiz in Training

Re: What does this mean?

 
1
  #15
Sep 10th, 2004
Just put a
  1. cin.get()
at the end of the code, exactly before
  1. return 0
command...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 5473 | Replies: 14
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC