C++ if statement block, Prints a message depending on years of service

Description

C++ if statement block, Prints a message depending on years of service

#include <iostream>
using namespace std;
int main()/*  w w w.ja va  2s.  c om*/
{
   int yrs;
   cout << "How many years of service? ";
   cin >> yrs;   // Determine the years they have worked.
   if (yrs > 20)
   {
      cout << "Give a gold watch\n";
   }
   else
   {
      if (yrs > 10)
      {
         cout << "Give a paper weight\n";
      }
      else
      {
         cout << "Give a pat on the back\n";
      }
   }
   return 0;
}



PreviousNext

Related