Write a C# program that prompts a user to enter a birth month and day. Display an error message if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message.
Here is the code for you:
using System.IO;
using System;
class Program
{
static void Main()
{
int month, day;
//Prompts a user to enter a birth month and day.
Console.Write("Please enter your month of birth: ");
month = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter your day of birth: ");
day = Convert.ToInt32(Console.ReadLine());
//Display an error message if the month is invalid (not 1 through
12)
//or the day is invalid for the month
//If the month and day are valid, display them with a
message.
if(month == 1 || month == 3 || month == 5 || month == 7 || month ==
8 || month == 10 || month == 12)
if(day <= 31 && day >= 1)
Console.WriteLine("Your entry is valid.");
else
Console.WriteLine("Your entry is Invalid.");
else if(month == 4 || month == 6 || month == 9 || month ==
11)
if(day <= 30 && day >= 1)
Console.WriteLine("Your entry is valid.");
else
Console.WriteLine("Your entry is Invalid.");
else if(month == 2)
if(day <= 29 && day >= 1)
Console.WriteLine("Your entry is valid.");
else
Console.WriteLine("Your entry is Invalid.");
else
Console.WriteLine("Your month is Invalid.");
}
}
And the ouput screenshot is:
Write a C# program that prompts a user to enter a birth month and day. Display...
Write a program named CheckMonth2 that prompts a user to enter a birth month and day. Display an error message that says Invalid date if the month is invalid (not 1 through 12) or the day is invalid for the month (for example, not between 1 and 31 for January or between 1 and 29 for February). If the month and day are valid, display them with a message. For example, if the month entered is 2, and the day...
Write a program in visual c# program named CheckMonth that prompts a user to enter a birth month. If the value entered is greater than 12 or less than 1, display an error message; otherwise, display the valid month with a message such as 3 is a valid month.
Write a program that prompts the user to enter a person's birth date in numeric form (e.g. 8-27-1980) and outputs the date of birth in the format of month day, year (e.g. August 27, 1980). Your program must work for three types of exceptions - invalid day, invalid month and invalid year (year must be between 1915 and 2015). Make these as class driven exceptions. Use one try-catch block with separate catches for the exception classes to handle errors for...
Write program that prompts the user to enter a person's date of birth in numeric form such as 8-27-1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Similar conventions for the invalid values of month and year. (Note that your program must handle...
In ruby Write a program that prompts the user to enter a year and first day of the year, and displays the calendar table of that year. For example, if the user entered the year 2019, and 2 for Tuesday, January 1, 2019, your program should display the calendar for each month in the year 2019.
Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. For example if you enter 10 and 9 and 12, in the result we will first see 9, then 10 and then 12 (because 9 < 10 < 12). **using c++
Write a code segment that prompts the user to enter a double number between (5.55 and 123.3) inclusive. If the input is invalid, print an error message and loop until the input is valid. Code in c++
C Programming Quesition (Structs in C): Write a C program that prompts the user for a date (mm/dd/yyyy). The program should then take that date and use the formula on page 190 (see problem 2 in the textbook) to convert the date entered into a very large number representing a particular date. Here is the formula from Problem 2 in the textbook: A formula can be used to calculate the number of days between two dates. This is affected by...
JAVA 2. (8 points) Write a code segment which prompts the user to enter the price of a tour and receives input from the user. A valid tour price is between $52.95 and $259.95, inclusive. Your program should continue to repeat until a valid tour price has been entered. If the user enters an invalid price, display a message describing why the input is invalid. You may assume that the user only enters a real number. The user will not...
1. Write a program that prompts the user to enter three integers and display the integers in non-decreasing order. You can assume that all numbers are valid. For example: Input Result 140 -5 10 Enter a number: Enter a number: Enter a number: -5, 10, 140 import java.util.Scanner; public class Lab01 { public static void main(String[] args) { Scanner input = new Scanner(System.in); } } ---------------------------------------------------------------------------------------------------------------------------- 2. Write a program that repeatedly prompts the user for integer values from...