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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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