MuffinMonster

Class Task 5#

Oct 4th, 2013
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int day, month, year;
  14.             Console.WriteLine("Please enter a date: Day, month, year (yyyy):");
  15.             Console.Write("Day: ");
  16.             day = int.Parse(Console.ReadLine());
  17.             while (day < 1 || day > 31)
  18.             {
  19.                 Console.Write("Re-enter the day so it will be vaild (1 - 31)");
  20.                 day = int.Parse(Console.ReadLine());
  21.  
  22.             }
  23.             Console.Write("Month: ");
  24.             month = int.Parse(Console.ReadLine());
  25.             while (month < 1 || month > 12)
  26.             {
  27.                 Console.Write("Re-enter the month so it will be vaid (1 - 12): ");
  28.                 month = int.Parse(Console.ReadLine());
  29.             }
  30.             Console.WriteLine("REMINDER: The year can only be between 1900 to 2013");
  31.             Console.Write("Year: ");
  32.             year = int.Parse(Console.ReadLine());
  33.             while (year < 1900 || year > 2013)
  34.             {
  35.                 Console.Write("Re-enter the year so it will be vaild (1900 - 2013): ");
  36.                 year = int.Parse(Console.ReadLine());
  37.             }
  38.             switch (month)
  39.             {
  40.                 case 4:
  41.                 case 6:
  42.                 case 9:
  43.                 case 11: if (day > 30)
  44.                         Console.WriteLine("The day is not vaild for this month!"); break;
  45.                 case 2: if (day > 28)
  46.                         Console.WriteLine("The day is not vaild for this month!"); break;
  47.                 default: Console.WriteLine("The date is fine!"); break;
  48.             }
  49.             Console.Write("The date you've typed is: " + day + "/" + month + "/" + year);
  50.             Console.ReadKey();
  51.  
  52.         }
  53.     }
  54. }
Add Comment
Please, Sign In to add comment