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

  Stability in an ever-changing technology world

Where do you think C++ and coding games in C++ is headed in the next five years? How about in the next 10 years? Do you think there are any significant improvements that need to be made to the code to ensure its stability in an ever-changing t..

  Write a function sum3darray

Write a function sum3DArray. This function will take a three dimensional array of ints and add all the entries in the three dimensional array. Assume columns and rank are two constants already defined.

  Provide a three-argument constructor

Create a class called Point that has two data members: x- and y-coordinates of the point. Provide a no-argument and a 2-argument constructor - Provide a three-argument constructor

  Declare a vector

Declare a vector of these structures where the size of the vector is to be 7.

  Create an object oriented solution customer to purchase

Create an object oriented solution that allows a customer to purchase between 1 and 3 pizzas, add toppings to each pizza, if desired, and then displays a receipt, including the details for each pizza, a pretax total amount, and a grand total amoun..

  Prepare a program for sorting the numbers

Write a program that orders three double numbers by increasing value. The program should include a function named sort3 that takes three double * arguments (pointer to double). The function prototype is void sort3(double *x, double *y, double *z);

  Evaluate the roots of the 2nd order equation

Write a 'C' program to evaluate the roots of the 2nd order equation - Ensure that your program includes the solutions for the subsequent SPECIAL cases

  Multiple choice question on c programming

Create a function to print "88 is a great port number" function name is yourName_PrintFunction no input no return type print "88 is a great port number"

  State diagram to recognize one form

Design a state diagram to recognize one form of the comments of the C-based programming languages, those that begin with /* and end with */. and also Write and test the code to implement the state diagram.

  Design-analysis-coding and testing

For this assignment you will be provided with incomplete sample starter code that you can modify and build upon. Your task will be to carry out the design, analysis, coding and testing to add several additional features to this sample code. You ar..

  Calculates the average of three test scores

Write a program that calculates the average of three test scores. The program should contain three value-returning functions: main, getTestScore, and calcAverage

  Develop a class airborne location

develop a class AirborneLocation that represents the location of airplanes with respect to a reference radar location. Each AirborneLocation object should include data member for aircraftID (integer),

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