lesson 8 getscore cpp
[[lesson_8_getscore_cpp]] last edit on Aug 10, 2005 3:27 AM by rescued_by_c

[user02@FC4 Lesson08]$ cat -n getscore.cpp
   1  #include <iostream>
   2  using namespace std;
   3
   4  int main()
   5  {
   6     int test_score;
   7
   8     cout << "Type in the test score and press Enter: ";
   9     cin >> test_score;
  10
  11     if (test_score >= 90)
  12        {
  13           cout << "Congratulations, you got an A!" << endl;
  14           cout << "Your test score was " << test_score << endl;
  15        }
  16     else
  17        {
  18           cout << "You should have worked harder!" << endl;
  19           cout << "You missed " << 100 - test_score << " points " << endl;
  20        }
  21
  22     return 0;
  23  }
[user02@FC4 Lesson08]$ g++ -o getscore getscore.cpp
[user02@FC4 Lesson08]$ ./getscore
Type in the test score and press Enter: 89
You should have worked harder!
You missed 11 points
[user02@FC4 Lesson08]$ ./getscore
Type in the test score and press Enter: 93
Congratulations, you got an A!
Your test score was 93