Problem Solving Using Computers

Tom Kelliher, CS17

Feb. 9, 1996

We will be going into the lab. Our goal is to accomplish the following things:

  1. Power-up, power-down sequence
  2. Login to Novell (I hope you know your password!)
  3. Use netscape (or Webexplorer in the other labs) to print a copy of the homework assignment
  4. Print a copy of your homework
  5. Compile and run a program
  6. Save the program on your N drive
  7. Print a program listing

Enter, compile, and run the following program:

#include <iostream.h>

const int MAX_STRING = 30;
const int CURRENT_YEAR = 1996;
const long DELAY = 10000000;

int main()
{
   char name[MAX_STRING];
   int age;
   int birthYear;
   char response;
   long delay;

   cout << "Hi!  I'm Felix." << endl;
   cout << "What's  your name? ";
   cin.getline(name, MAX_STRING);

   cout << "How old are you, " << name << "? ";
   cin >> age;

   if (age >= 19)
      cout << "You're OLD!!" << endl;

   birthYear = CURRENT_YEAR - age - 1;

   cout << "Were you born in " << birthYear << "? (y or n) ";
   cin >> response;

   if (response == 'y')
      cout << "I'm smart, aren't I?" << endl;
   else
      cout << "Your birthday is too early in the year!" << endl;

   delay = DELAY;
   while (delay > 0)
       delay = delay - 1;

   cout << endl << "Well, gotta go.  See you next time!!"
        << endl << endl;

   return 0;
}



Thomas P. Kelliher
Thu Feb 8 14:13:10 EST 1996
Tom Kelliher