The third day of class

Source: Internet
Author: User

Title: Input two number, if the two number squared is greater than 100, the output of more than hundred digits, if the two number of squares less than 100, then output two number of the sum;

Console.Write ("Please enter the first number a=");

Double A = double. Parse (Console.ReadLine ());

Console.Write ("Please enter a number b=");

Double b = Double. Parse (Console.ReadLine ());

if (A * a + b * b > 100)

{

Double x = Convert.ToInt32 ((A * a + b * b)/100);

Console.WriteLine ("The sum of the squares of two numbers and the hundred and hundreds above are:" +x);

}

Else

{

Double y = a * a + b * b;

Console.WriteLine ("The sum of squares of two numbers is:" +y);

}

Knowledge point: Structure; Switch (variable) {case: program; break; default:break;}

1. Hamburgers, 2. French fries 3. Chicken Nuggets 4. Chicken Leg 5 chicken rice flower; Tells the user the selected food according to the number entered;

Console.Write ("Strong Enter the number of food you want A=");

int a = Int. Parse (Console.ReadLine ());

Switch (a)

{

Case 1:

Console.WriteLine ("Your choice is chicken leg");

Break

Case 2:

Console.WriteLine ("You have chosen a hamburger");

Break

Default

Console.WriteLine ("Your input is incorrect");

Break

}

Title: Enter a date to determine whether the format is correct;

first, the year should be greater than 0 less than 9999, the month should be greater than 0 less than 13, the most important thing is to pay attention to each size the number of days in the month and leap years common year February days are different.

Console. Write ("Please enter the year year=");

int y = Int. Parse (Console.ReadLine ());

Console.Write ("Please enter month math=");
int m = Int. Parse (Console.ReadLine ());
Console.Write ("Please enter date day=");
int d = Int. Parse (Console.ReadLine ());
if (Y > 0 && y < 9999)
{
if (M > 0 && m < 13)
{
if (m = = 1 | | m = = 3 | | m = = 5 | | m = = 7 | | m = = 8 | | m = = | | m = = 12)
{
if (d > 0 && D < 32)
Console.WriteLine ("You enter the year:" + y + "year" + M + "month" + D + "Day" + "correct");
Else
Console.WriteLine ("You entered the wrong year!") ");
}
else if (m = = 4 | | m = = 6 | | m = = 9 | | m = = 11)
{
if (d > 0 && D < 31)
Console.WriteLine ("You enter the year:" + y + "year" + M + "month" + D + "Day" + "correct");
Else
Console.WriteLine ("You entered the wrong year!") ");
}
Else
{
if (y% 4 = = 0 && y% = 0 | | y% 400 = 0)
{
if (d > 0 && D < 30)
Console.WriteLine ("You enter the year:" + y + "year" + M + "month" + D + "Day" + "correct");
Else
Console.WriteLine ("You entered the wrong year!") ");
}
Else
{
if (d > 0 && D < 29)
Console.WriteLine ("You enter the year:" + y + "year" + M + "month" + D + "Day" + "correct");
Else
Console.WriteLine ("You entered the wrong year!") ");
}

}

}
Else
Console.WriteLine ("You entered the wrong year!") ");

}
Else
Console.WriteLine ("You entered the wrong year!") ");

The third day of class

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.