home *** CD-ROM | disk | FTP | other *** search
/ Beginning C++ Through Gam…rogramming (2nd Edition) / BCGP2E.ISO / source / chapter01 / game_stats.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2003-09-17  |  941 b   |  44 lines

  1. // Game Stats
  2. // Demonstrates declaring and initializing variables
  3.  
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int score;                
  10.     double distance;        
  11.     char playAgain;            
  12.     bool shieldsUp;            
  13.  
  14.     short lives, aliensKilled;
  15.  
  16.     score = 0;
  17.     distance = 1200.76;
  18.     playAgain = 'y';
  19.     shieldsUp = true;
  20.     lives = 3;
  21.     aliensKilled = 10;
  22.         
  23.     double engineTemp = 6572.89;
  24.  
  25.     cout << "\nscore: "        << score << endl;
  26.     cout << "distance: "    << distance << endl;
  27.     cout << "playAgain: "    << playAgain << endl;
  28.     //skipping shieldsUp since you don't generally print Boolean values
  29.     cout << "lives: "        << lives << endl;
  30.     cout << "aliensKilled: "<< aliensKilled << endl;
  31.     cout << "engineTemp: "    << engineTemp << endl;
  32.  
  33.     int fuel;
  34.     cout << "\nHow much fuel? ";
  35.     cin >> fuel;
  36.     cout << "fuel: " << fuel << endl;
  37.  
  38.     typedef unsigned short int ushort;
  39.     ushort bonus = 10;
  40.     cout << "\nbonus: " << bonus << endl;
  41.  
  42.     return 0;
  43. }
  44.