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

  Prepare program to check the syntax of the english language

Determine the form of the output dependent on the coefficients being input. Print and evaluate with peers in class."

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

  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.

  Using an abstract class with only pure virtual functions

Using an abstract class with only pure virtual functions, create three small classes unrelated by inheritance---clases Building, Car and Bicycle. Give each class some uique appropriate attributes and behaviors that it does not have in common with oth..

  What does the term polymorphism mean

What does the term polymorphism mean? Provide an example.

  Definitions of the class circularlinkedlist

Write the definitions of the class circularLinkedList and its member functions. (You may assume that the elements of the circular linked list are in ascending order.)

  Write a program for a palindrome

Write a program for A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindromes with minimum number of character replacements..

  Show the restriction range of values from rand

How to write a program to demonstrate the use of random number functions in c++ program. and to show the restriction range of values from rand()using %

  Write a program that prompts the user to input

One metric ton is approximately 2205 pounds. Write a program that prompts the user to input the amount of rice, in pounds, in a bag. The program outputs the number of bags needed to store one.

  Write a function named dietoss that simulates the tossing

Write a function named dieToss that simulates the tossing of two dice. When you call the function, it should generate two random numbers ranged in 1 to 6 and return the sum of the die's numbers. In the mail program, ask user how many times the dice s..

  Write an algorithm to compute the volume of water

Write an algorithm to compute the volume of water in cubic feet, flowing through a pipe of diameter d in feet, with a velocity of v feet per second.

  Inserts a node with info value x

Complete the code for a function that inserts a node with info      value x before, and a node with info value zafter,each node with      info value y in a linked list with first node pointer p.

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