BreakContinueDemo

import

java.util.Scanner;

 

class

ClassA {

 

public static void main(String[] args) {

 

// int i = 1;

// switch (i) {

// case 1:

// System.out.println("i = 1");

// case 2:

// System.out.println("i = 2");

// default:

// System.out.println("i = default");

 

// int j=0;

// for(;;){

// System.out.println("j=" + j);

 

// }

 

// boolean isNegative = false;

// Scanner input = new Scanner(System.in);

// for(int i=0; i<20; i++){

// System.out.println("please input i");

// int score = input.nextInt();

//

// if(score<0){

// isNegative = true;

// break;

// }

// }

 

String name = "mabel";

String psd = "123456";

 

Scanner input = new Scanner(System.in);

 

for (int i = 2; i >= 0; i--) {

 

System.out.print("please input the user name: ");

String inputName = input.next();

System.out.print("please input the password: ");

String passWord = input.next();

if (!inputName.equals(name) || !passWord.equals(psd)) {

 

System.out.println("incorrect input! you still have" + " " + i + " " + " chances");

if (i == 0) {

System.out.println("sorry, you have entered 3 times incorrectly!");

}

continue;

 

} else {

System.out.println("welcome!!");

break;

}

 

}

 

}

}

posted @ 2016-09-23 13:35  mabelfdm  阅读(78)  评论(0编辑  收藏  举报