Program to read in the number of a month

Assignment Help C/C++ Programming
Reference no: EM13806370

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);

}

}

}

Reference no: EM13806370

Questions Cloud

Standardize network configurations : As the network engineer, you have been asked to standardize network configurations across the Devry University campus. This week, your manager has scheduled a meeting to discuss with you specific configuration requirements based on camera density
Scooter passed inspection probability based problems : what is the probability that if a randomly selected scooter did not pass inspection, it came from assembly line B?
Apply a sociological perspective to the social world : Apply a sociological perspective to the social world
A firm has a perfectly competitive production function : Suppose a firm has a perfectly competitive production function: q=f(K,L)=2(K^1/2)+2(L^1/2). Suppose the price of capital is r and the price of labor is w. 1) The firm's cost minimization problem can be wrtten as: 2) Find the conditional input demand ..
Program to read in the number of a month : 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
Write an essay about about picasso and matisse : Write an essay about about Picasso and Matisse and their painting.
Consider a market with both foreign and domestic ( : Let's consider a market with both foreign and domestic (i.e. U.S.) production. Suppose that domestic (U.S.) demand is given by QD = 6000 - 50P and domestic supply is QS . Foreign producers can supply any quantity at a price of $40.
What is the approximate radius of a nucleus : What is the approximate radius of a nucleus - How many nuclei are present 1h and 49 min later?
Write an essay about the right of habeas corpus : Write an essay about the right of habeas corpus in the context of the war on terror. Your essay should address the following subtopics

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Compound operators or arithmetic assignment operators

Rewrite the given assignment statement using a combined assignment operator: (Use single spaces between operands and operators)

  Expressions until the user says

Expressions until the user says he or she wishes to end the program. For a more difficult assignment, enhance your program so that the expression need not be well formed; if it is not well formed, then the user is asked to reenter the expression.

  Base process which communicate with child processes

Write a program which has a "base process" which communicates with child processes acting as "bombers" that it creates.

  Create a detailed ipo chart

Create a detailed IPO chart that also includes the algorithm from the attached c++ source code.

  Write a program that reads the scores from the file

Write a program that reads the scores from the file and displays their total and average. Scores are separated by blanks.

  Design a modularized body mass index program

Design a modularized Body Mass Index (BMI) Program which will calculate the BMI of a team player. The formula to calculate the BMI is as follows:  BMI = Weight * 703/Height2

  Two-dimensional array of double to hold the sales

Suppose you have a two-dimensional array of double to hold the sales amounts for all your salespeople three years. Assume you employ 50 salespeople and this array already holds valid data.

  Two dimensional int array to hold the prices of the seats

The Theater class shows a theater with an auditorium containing a fixed number of seats arranged in rows with each seat selling for a exacting price. The instance variables for the theater are:

  Prepare a program for a company named retail-martbullprompt

prepare a program for a company named retail-mart.bullprompt the user to enter an item name one word only a quantity

  Display a report showing the energy produced

Open the data file Energy.dat and read each column into an array - Display a report showing the energy produced and the percentage of the grand total energy for each of the 13 types of energy for a given year. Prompt the user to enter the year.

  Write a pseudocode statement

Assume that a program has two string variables named str1 and str2. Write a pseudocode statement that assigns an all uppercase version of str1 to the str2 variable. is str.add(str1,str2) part of it?

  Write a program to calculate existing angles and do if and

write a program to calculate existing angles and do if and then from this and to place fixed angles at certain position

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd