Program to read in the number of a month and output the


Program to read in the number of a month and output the name of the month.

Then the user is asked if they want to know the number of days in that month and if so output the number of days. Assuming that there are no leap years and February ALWAYS has 28 days only. A switch Must be used in this program (at the minimum to select the number of days in the month).

{

class Program

{

static void Main(string[] args)

{

string input = "";

string output = "";

string[] month = new string[13];

int monthNum = 0;

bool tray = true;

month[0] = "0";

month[1] = "January";

month[2] = "February";

month[3] = "March";

month[4] = "April";

month[5] = "May";

month[6] = "June";

month[7] = "July";

month[8] = "August";

month[9] = "September";

month[10] = "October";

month[11] = "November";

month[12] = "December";

do

{

Console.Write("Enter Number Of Month: ");

input = Console.ReadLine();

monthNum = int.Parse(input);

if (monthNum 12)

{

Console.WriteLine(" ERROR! ");

tray = true;

continue;

}

else

{

output = String.Format("Month Num.{0} is: {1}.", monthNum, month[monthNum]);

Console.WriteLine(output);

 

Console.Write("do you want to know the number of days in {0}? y(Yes), n(No): ", month[monthNum]);

input = Console.ReadLine();

if (input[0] == 'y' | input[0] == 'Y')

{

switch (monthNum)

{

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:

Console.WriteLine("Days in {0} is 31 days.", month[monthNum]);

break;

case 4:

case 6:

case 9:

case 11:

Console.WriteLine("Days in {0} is 30 days.", month[monthNum]);

break;

default:

Console.WriteLine("Days in {0} is 28 days.", month[monthNum]);

break;

}

}

}

Console.Write(" Start Again? y(Yes), n(No) : ");

input = Console.ReadLine();

if (input[0] != 'y' & input[0] != 'Y')

tray = false;

else

Console.Clear();

}

while (tray);

}

}

}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Program to read in the number of a month and output the
Reference No:- TGS01086619

Expected delivery within 24 Hours