Note: Clear the logic, draw a logical branch diagram, clarify the idea
1.if statements
2.if...else statements
3.if.. else If...else
1 Static voidMain (string[] args)2 {3Console.WriteLine ("Enter score:");4 5 stringFS =console.readline ();6 intScore =Convert.ToInt32 (FS);7 8 #regionJudging Fractions9 if(Score >=0&& Score < -)Ten { OneConsole.WriteLine ("Fail to pass, retake"); A } - Else if(Score >= -&& Score < the) - { theConsole.WriteLine ("congratulations on passing ."); - } - Else if(Score >= the&& score <= -) - { +Console.WriteLine ("Congratulations, excellent ."); - } + Else A { atConsole.WriteLine ("wrong input"); - } - #endregion - -Console.WriteLine ("End"); -}
3. Enter the score, if it is less than 60, then judge the addition, and then the output is passed
1 Static voidMain (string[] args)2 {3Console.WriteLine ("Enter score:");4 5 stringFS =console.readline ();6 intScore =Convert.ToInt32 (FS);7 8 if(Score < -)9 {TenConsole.WriteLine ("Do you do your homework carefully? (yes, no)"); One A stringZuoye =console.readline (); - - #region====== Plus points ======= the if(Zuoye = ="is a") - { -Score = score +5; - + if(Score < -) - { +Console.WriteLine ("inferior lattice"); A } at Else - { -Console.WriteLine ("Pass the exam ."); - } - } - Else in { -Console.WriteLine ("I failed."); to } + #endregion - } the Else * { $ Panax Notoginseng } - theConsole.WriteLine ("End"); +}
VS Review--if else and if else nested statements