public static void main(String[] args) { Scanner input = new Scanner(System.in); String trueP = "123"; int i=3; do{ i--; System.out.println("请输入密码:"); String pass = input.next(); if(trueP.equals(pass)){ break; } if(i ==0){ System.out.println("机会使用完毕"); return; } System.out.println("密码不正确,还剩" + i + "次机会"); }while(i>0); System.out.println("密码正确,可以执行取钱操作"); }
标签:String,校验,System,密码,pass,println,out From: https://www.cnblogs.com/19981206-zxb/p/16888211.html