A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© 哒哒哒哒 初级黑马   /  2018-1-10 17:28  /  1697 人查看  /  7 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文



                String username ="Dmy;
                String password ="123456";
                Scanner scanner = new Scanner(System.in);
       
               
                int count =0;
       
                while(count<3){
                        System.out.println("请输入用户名");
                        String name = scanner.nextLine();
                        System.out.println("请输入密码");
                        String word = scanner.nextLine();
                        if(username.equals(name)&&password.equals(word)){
                                System.out.println("登录成功");
                          break;
                        }else {
                                System.out.println("登录失败");
                               
                                if(2-count!=0){
                                        System.out.println("您的登录次数还剩下"+(2-count)+"次");
                                }else{
                                        System.out.println("您今日的登录次数已经用完,请明日再试");
                                }
       
                                count++;       
                                       
                                }               
                               
                       
                }
总结:    努力学习,天天向上!!!


{:8_472:}{:8_472:}{:8_502:}

7 个回复

正序浏览
继续加油哦   
回复 使用道具 举报
v继续加油哦     
回复 使用道具 举报
期待你每天的进步   温故而知新
回复 使用道具 举报

好好学习,天天向上!
回复 使用道具 举报
好好学习,天天向上!
回复 使用道具 举报
努力学习,天天向上!!!
回复 使用道具 举报
期待继续更新,加油哦
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马