练习1——Scanner



/**s
 * 〈一句话功能简述〉<br> 
 * 〈获取键盘〉
 *
 * @author abu
 * @create 2019/7/4
 * @since 1.0.0
 */
public class TestScanner {
    public static void main(String[] args){
        /*test1 从键盘获取值
        Scanner s = new Scanner(System.in);
        System.out .println("请随意敲击键盘");
        String str = s.next();
        System.out.println(str);
        */

        /*testIf2 从键盘获取值之后给出不同结果
        Scanner s = new Scanner(System.in);
        System.out.println("你考了多少分呀?");
        int score = s.nextInt();

        if (score >=100 || score < 0){
            System.out.println("are you sure what you import is right?");
        }
        else{
            if (score == 100){
                System.out.println("你可以获得BMW");
            }
            else if(score > 80 && score <= 90){
                System.out.println("给你个iPhone5");
            }
            else if(score >= 60 && score <= 80){
                System.out.println("给你一本书把~");
            }
            else{
                System.out.println("you are so poor to get nothing!");
            }
        }
        */
        /*testIf3 输入三个数字,自动从大到小排列
        Scanner s = new Scanner(System.in);
        System.out.println("please import the first number");
        int num1 = s.nextInt();
        System.out.println("please import the second number");
        int num2 = s.nextInt();
        System.out.println("please import the third number");
        int num3 = s.nextInt();


        System.out.println("the sort from the largest to the smallest is");

        if(num1 > num2){
            if(num3 > num1) {
                System.out.println(num3 + "," + num1 + ","  + num2 );
            }else if(num3 < num2){
                System.out.println(num1 +","  + num2 + "," + num3 );
             }else{
                System.out.println(num1 + ","  + num3 +","  + num3 );
            }
        }
        else{
            if(num3<num1){
                System.out.println(num2 +","  + num1 +","  + num3 );
            }
            else if(num3>num2){
                System.out.println(num3 + ","  + num2 +","  + num1 );
            }
            else{
                System.out.println(num2 + ","  + num3 + ","  + num1 );
            }
        }
        */
        //根据男生不同的条件判断是否嫁给他
       /* Scanner s = new Scanner(System.in);
        System.out.println("男生身高是多少呀?");
        int height = s.nextInt();
        System.out.println("男生有多少万财产呀?");
        double assets = s.nextDouble();
        System.out.println("男生帅吗?");
        boolean looks = s.nextBoolean();

        System.out.println("那你嫁不嫁啊?");

        if (height > 180 & assets > 1000 & looks == true){
            System.out.println("哦他是真命天子");
        }
        else if(height > 180 | assets > 1000 | looks == true)
            System.out.println("还行,嫁吧...");
        else{
            System.out.println("你是好人!");
        }
        */



    }
}


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值