Make your own free website on Tripod.com

//*********************************************************
//* This program prints months of the year and prints the *
//* time of the day. *
//********************************************************

void main()
{

int month, time;
char ampm;

cout << "enter the month number:" << '\n';
cin >> month;

cout << "enter the numeric time:" << '\n';
cin >> time;

cout << "enter A/P for AM/PM:" << '\n';
cin >> ampm;

if ( ampm = 'a' )
ampm = 'A';

if ( ampm = 'p' )
ampm = 'P';


switch ( month )
{
case 1 :
cout << "month is JANUARY";
break;
case 2 :
cout << "month is FEBRUARY";
break;
case 3 :
cout << "month is MARCH";
break;
case 4 :
cout << "month is APRIL";
break;
case 5 :
cout << "month is MAY";
break;
case 6 :
cout << "month is JUNE;
break;
case 7 :
cout << "month is JULY";
break;
case 8 :
cout << "month is AUGUST";
break;
case 9 :
cout << "month is SEPTEMBER";
break;
case 10 :
cout << "month is OCTOBER";
break;
case 11 :
cout << "month is NOVEMBER";
break;
case 12 :
cout << "month is DECEMBER";
break;
default :
cout <<"invalid month entered";
break;
}

if ( ampm = 'A' )
{
if ( time >= 12 )
cout << " its midnight" << '\n';
else
cout << " its morning" << '\n';
}

if ( ampm = 'P' )
{
if ( time >= 12 )
cout << " its afternoon" << '\n';
else
cout << " its evening" << '\n';
}

}