Classic examples of C # language

Source: Internet
Author: User

Two examples are written in two different ways

One is a console.write ();

One no, both of them can be

Standard weight
Men's weight = height-100 +-3
Kgcm
Female weight = height-110 +-3

Console.Write ("Please enter gender");
String xb = Console.ReadLine ();
Console.Write ("Please enter your weight");
Double TZ = Double. Parse (Console.ReadLine ());
Console.Write ("Please enter your height");
Double sg = double. Parse (Console.ReadLine ());
if (XB = = "Male")
{
Double n = tz-sg + 100;
if (n <= 3 && 3 <= N)
{
Console.WriteLine ("Standard Weight");
}
else if (n <-3)
{
Console.WriteLine ("Eat a little more");
}
Else
{
Console.WriteLine ("Eat Less");
}
}
else if (XB = = "female")
{
Double m = tz-sg + 110;
if (M <= 3 &&-3 <= m)
{
Console.WriteLine ("Standard Weight");
}
else if (M <-3)
{
Console.WriteLine ("Eat a little more");
}
Else
{
Console.WriteLine ("Eat Less");
}
}

Please enter your score: "
Less than 0, greater than 100, "the input score is wrong!" ”
Greater than 0, less than 10, "less lattice! Learn the slag! ”
Less than 60, "the inferior lattice! Keep trying! ”
Greater than or equal to 60, "Congratulations! Passed the exam! ”
Greater than or equal to 90, "Genius! It's awesome! ”

String Fenshu = "Please enter your score";
Console.WriteLine (Fenshu);
string x = Console.ReadLine ();
int fs = Convert.ToInt32 (x);
if (FS < 0 | | FS > 100)
{
Console.WriteLine ("Input error, please re-enter");

}
else if (fs > 0 && FS < 10)
{
Console.WriteLine ("Fail, learn Slag");
}
else if (<= FS && FS < 60)
{
Console.WriteLine ("Fail, next effort");
}
else if (fs > && FS < 90)
{
Console.WriteLine ("Congratulations, you passed");
}
else if (fs > && FS > 60)
{
Console.WriteLine ("Genius Ah");
}

Classic examples of C # language

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.