Conditional statements for the Java Foundation

Source: Internet
Author: User

http://www.verejava.com/?id=16992610131518

/*流程控制语句分为1. 条件语句2. 分支语句3. 循环语句*/import java.util.Scanner;public class Statement{    public static void main(String[] args)    {        //1.条件语句        /*            包括:                1. if(表达式){语句}                2. if(表达式){语句}else{语句}                3. if(表达式){语句}else if{语句}        */        Scanner in=new Scanner(System.in);        System.out.println("请输入您的考试成绩...");        int score=in.nextInt();        if(score>=90)        {            System.out.println("奖励一朵红花");        }        else if(score>=60&&score<90)        {            System.out.println("没有奖励,只有鼓励,革命尚为成功,同志继续努力");        }        else if(score<60)        {            System.out.println("挨打");        }    }}/*  如果在判断条件很多的时候if{}else{} 显得有点臃肿和难读, 这样的情况下我们一般选择  分支语句 switch(表达式){}*/

http://www.verejava.com/?id=16992610131518

Conditional statements for the Java Foundation

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.