Switch Case Statement
Enter a year and a month, judging is the day of the first day?
Console.WriteLine ("Please enter the Year:");
int year = Int. Parse (Console.ReadLine ());
Console.WriteLine ("Please enter the month:");
int month = Int. Parse (Console.ReadLine ());
Console.WriteLine ("Please enter the day:");
int day = Int. Parse (Console.ReadLine ());
int sum=0;
If ((year% 400 = = 0) | | (Year% + = 0) && (year% 4 = = 0)))
{
Switch (month)
{
Case 1:
Sum =day;
Break
Case 2:
Sum =day + 31;
Break
Case 3:
Sum =day + 31 + 29;
Break
Case 4:
Sum =day + 31 + 29 + 31;
Break
Case 5:
Sum =day + 31 + 29 + 31 + 30;
Break
Case 6:
Sum =day + 31 + 29 + 31 + 30 + 31;
Break
Case 7:
Sum =day + 31 + 29 + 31 + 30 + 31 + 30;
Break
Case 8:
Sum =day + 31 + 29 + 31 + 30 + 31 + 30 + 31;
Break
Case 9:
Sum =day + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31;
Break
Case 10:
Sum =day + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30;
Break
Case 11:
Sum =day + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;
Break
Case 12:
Sum =day + 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;
Break
Default
Console.WriteLine ("Input Error");
Break
}
}
Else
{
Switch (month)
{
Case 1:
Sum =day;
Break
Case 2:
Sum =day + 31;
Break
Case 3:
sum = day + 31 + 28;
Break
Case 4:
Sum =day + 31 + 28 + 31;
Break
Case 5:
Sum =day + 31 + 28 + 31 + 30;
Break
Case 6:
Sum =day + 31 + 28 + 31 + 30 + 31;
Break
Case 7:
Sum =day + 31 + 28 + 31 + 30 + 31 + 30;
Break
Case 8:
Sum =day + 31 + 28 + 31 + 30 + 31 + 30 + 31;
Break
Case 9:
Sum =day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31;
Break
Case 10:
Sum =day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30;
Break
Case 11:
Sum =day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31;
Break
Case 12:
Sum =day + 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30;
Break
Default
Console.WriteLine ("Input Error");
Break
}
}
Console.WriteLine ("This is {1} days of {0} years", year,sum);
Switch Case statement