C # Fifth session

Source: Internet
Author: User
Tags switch case

Switch statement

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;

Namespace @switch
{
Class Program
{
static void Main (string[] args)
{
for (;;)
{
Switch Case Selection Statement
int m1 = to, M2 = 30, M3 = to, M4 =, M5 = To, M6 =--M7 =--M8 = =, M9 =-M10
Console.Write ("Please enter month =");
int a = Int. Parse ((Console.ReadLine ()));
if (a < a && a > 0)
//{
Console.Write ("Please enter the day =");
int b = Int. Parse ((Console.ReadLine ()));
if ((((A = = 1 | | a = 3 | | a = = 5 | | a = = 7 | | a = 8 | | a = = Ten | | a =)) && (b > 0 && B < 32 )) || ((A = = 4 | | a = = 6 | | a = = 9 | | a = = one) && (b > 0 && B < 31)) | | ((A = = 2) && (b > 0 && B < 29)))
// {
Switch (a)
// {
Case 1:
Console.WriteLine ("Over the Year" + (b) + "Day Out");
Break
Case 2:
Console.WriteLine ("Over the Year" + (M1 + B) + "Days Out");
Break
Case 3:
Console.WriteLine ("Over the Year" + (M1 + m2 + b) + "Days Out");
Break
Case 4:
Console.WriteLine ("Over the Year" + (M1 + m2 + m3 + b) + "Days Out");
Break
Case 5:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + m4 + B) + "Days Out");
Break
Case 6:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + m4 + M5 + B) + "Days Out");
Break
Case 7:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + B) + "Days Out");
Break
Case 8:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + B) + "Days Out");
Break
Case 9:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + B) + "Days Out");
Break
Case 10:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + B) + "Days Out");
Break
Case 11:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + M10 + B) + "Days Out");
Break
Case 12:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + M10 + M11 + B) + "Days Out");
Break
Default
Console.WriteLine ("You entered the wrong");
Break
// }
// }
Else
// {
Console.WriteLine ("You entered the wrong Day");

// }
//}
Else
//{
Console.WriteLine ("You entered the month in error");

//}

The judgment is not a leap year, the normal years, is a multiple of 4 but not a multiple of 100
Century the need is a multiple of 400
Enter a year to determine if it is leap years

int m1 = to, M3 = to, M4 = to, M5 = to, M6 =, M7 = to, M8 = to, M9 =, M10 = =, M11 = 30,m12=31;
int m2;
String y;
Console.WriteLine ("Please enter a year:");
int year = Int. Parse (Console.ReadLine ());
if (year >= 0 && year <= 9999)
{
If ((year% 4 = = 0 && year%! = 0) | | year% 400 = = 0)
{
y = "The year you entered is a leap years!" ";
m2 = 29;
}
Else
{
y = "You have entered common year!" ";
m2 = 28;
}
Console.WriteLine ("Please enter the month");
int a = Int. Parse (Console.ReadLine ());
if (a > 0 && a < 13)
{
Console.Write ("Please enter the day =");
int b = Int. Parse ((Console.ReadLine ()));
if ((((A = = 1 | | a = 3 | | a = = 5 | | a = = 7 | | a = 8 | | a = = Ten | | a = (0)) && (b > 32) || ((A = = 4 | | a = = 6 | | a = = 9 | | a = = one) && (b > 0 && B < 31)) | | ((A = = 2) && (b > 0 && B < (m2 + 1))))
{
Switch (a)
{
Case 1:
Console.WriteLine ("Over the Year" + (b) + "Day Out");
Break
Case 2:
Console.WriteLine ("Over the Year" + (M1 + B) + "Days Out");
Break
Case 3:
Console.WriteLine ("Over the Year" + (M1 + m2 + b) + "Days Out");
Break
Case 4:
Console.WriteLine ("Over the Year" + (M1 + m2 + m3 + b) + "Days Out");
Break
Case 5:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + m4 + B) + "Days Out");
Break
Case 6:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + m4 + M5 + B) + "Days Out");
Break
Case 7:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + B) + "Days Out");
Break
Case 8:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + B) + "Days Out");
Break
Case 9:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + B) + "Days Out");
Break
Case 10:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + B) + "Days Out");
Break
Case 11:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + M10 + B) + "Days Out");
Break
Case 12:
Console.WriteLine ("Past this year" + (M1 + m2 + m3 + M4 + M5 + M6 + M7 + m8 + M9 + M10 + M11 + B) + "Days Out");
Break
Default
Console.WriteLine ("You entered the wrong");
Break
}
Console.WriteLine (y+ "date is" +year+ "year" +a+ "month" +b+ "Day");
}
Else
{
Console.WriteLine ("You entered the wrong Day");
}
}
Else
{
Console.WriteLine ("You entered the month in error");
}
}
Else
{
Console.WriteLine ("You entered the wrong year");
}

Console.WriteLine ();
}
}
}
}

C # Fifth session

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.