C # if structure of basic exercises

Source: Internet
Author: User

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

Namespace if statement
{
Class Program
{
Static void Main (string [] args)
{

// If Michael's score is greater than 90, his father will reward him with 100 yuan.

Console. WriteLine ("Enter the score of Michael Jacob ");
Int cj = Convert. ToInt32 (Console. ReadLine ());
If (cj> 90)
{
/Console. WriteLine ("dad rewards 100 yuan ");
}
Else
{
Console. WriteLine ("let me write summary ");
}
Console. ReadKey ();

// 2 If Zhang San's Chinese score is greater than 90 and his music score is greater than 80, or his Chinese score is equal to 100 and his music score is greater than 70, the reward is 100 yuan.


Console. WriteLine ("Enter your Chinese score ");
Int chinese = Convert. ToInt32 (Console. ReadLine ());
Console. WriteLine ("Enter the music score of John ");
Int yinyue = Convert. ToInt32 (Console. ReadLine ());
Bool cj;
If (cj = chinese> 90 & yinyue> 80 | chinese ===100 & yinyue> 70)
{
Console. WriteLine ("dad rewards 100 yuan ");
}

Console. ReadKey ();

/// 3 pairs of final test scores (the user is required to enter a specific score of 0-, and the program displays a grade based on the score)
(Whether to use if or if-else)
Score> = 90
90> score> = 80 B
80> score> = 70 C
70> score> = 60 D
Score <60 E
Console. WriteLine ("enter a specific score ");
Int cj = Convert. ToInt32 (Console. ReadLine ());
If (cj> = 90)
{
Console. WriteLine ("");
}
If (cj <90 & cj> = 80)
{
Console. WriteLine ("B ");
}
If (cj <80 & cj> = 70)
{
Console. WriteLine ("C ");
}
If (cj <70 & cj> = 60)
{
Console. WriteLine ("D ");
}
If (cj <60)
{
Console. WriteLine ("E ");
}
Console. ReadKey ();

/// 4. the user is required to enter two numbers a and B. If a can be divisible by B or a plus B is greater than 100, a is output; otherwise, B is output.
Console. WriteLine ("enter a number ");
Int a = Convert. ToInt32 (Console. ReadLine ());
Console. WriteLine ("enter a number ");
Int B = Convert. ToInt32 (Console. ReadLine ());
If (a % B = 0 | a + B> 100)
{C
Console. WriteLine ("");
}
Else
{
Console. WriteLine ("B ");
}
Console. ReadKey ();

// 6. Ask the user to enter the user name and password. If the user name is admin and the password is mypass, the logon is successful.

Console. WriteLine ("enter the password :");
Int password = Convert. ToInt32 (Console. ReadLine ());


If (password = 888888)
{
Console. WriteLine ("correct ");

}
If (password! = 888888)
{
Console. WriteLine ("Enter again ");
}
If (password = 888888)
{
Console. WriteLine ("correct ");
}

Console. ReadKey ();
}
}
}


 

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.