import java.util.Scanner;
public? class? Demo18{
public? static? void main(String[] args){
//用戶登錄驗(yàn)證
//1屡萤、用戶名和密碼輸入正確
// 歡迎登錄MyShopping 系統(tǒng)
//2珍剑、如果用戶輸入的賬戶信息有誤
// ① 提示用戶輸入錯(cuò)誤,并顯示還有幾次機(jī)會(huì)
//3死陆、用戶輸入的錯(cuò)誤次數(shù)最多3次
// ①? 如果用戶輸入的錯(cuò)誤次數(shù)超過(guò)3次招拙,
// 提示:對(duì)不起,3次機(jī)會(huì)都輸入錯(cuò)了
Scanner sc = new Scanner(System.in);
int count = 0;
boolean flag = true;
do{
count ++;
System.out.print("用戶名:");
String? name = sc.next();
System.out.print("密碼:");
String? pwd = sc.next();
switch(name){
? case "jim":
switch(pwd){
? case "123456":
flag = false;
System.out.println("歡迎登錄MyShopping系統(tǒng)措译!");
}
}
if(flag){
System.out.println("輸入錯(cuò)誤别凤!還有"+(3-count)+"次機(jī)會(huì)");
if((3-count)==0){
flag=false;
}
}
}while(flag);
}
}