import java.util.Scanner;
//三层加密if-else嵌套,写if-else嵌套的时候从内到外
//import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
public class XunHunQianTao {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int y1 = 1234,y2 = 5678,y3 = 9012;
int m1,m2,m3;
int i = 1,k = 1,j = 1;
System.out.println("<<欢迎来到微盟加密公司>>");
System.out.println("友情提示,密码只能输入三次");
while(i <= 3)
{
System.out.println("请输入m1:");
m1 = input.nextInt();
if(m1 == y1)
{
System.out.println("请输入m2:");
m2 = input.nextInt();
if(m2 == y2)
{
System.out.println("请输入m3:");
m3 = input.nextInt();
if(m3 == y3)
{
System.out.println("恭喜你,输入正确");
break;
}
else
{
while(k <= 2)
{
System.out.println("输入错误,请重新输入m3:");
m3 = input.nextInt();
if(m3 == y3)
{
System.out.println("恭喜你,输入正确");
break;
}
k ++;
}
break;
}
}
else
{
while(j <= 2)
{
System.out.println("输入错误,请重新输入m2:");
m2 = input.nextInt();
if(m2 == y2)
{
System.out.println("请输入m3:");
m3 = input.nextInt();
if(m3 == y3)
{
System.out.println("恭喜你,输入正确");
break;
}
else
{
while(k <= 2)
{
System.out.println("输入错误,请重新输入m3:");
m3 = input.nextInt();
if(m3 == y3)
{
System.out.println("恭喜你,输入正确");
break;
}
k ++;
}
break;
}
}
j ++;
}
break;
}
}
i ++;
}
if(i == 4 || k == 3 || j == 3)
{
System.out.println("系统自动关闭");
}
}
}
来源:CSDN
作者:@大愚@
链接:https://blog.csdn.net/qq_43728862/article/details/104791705