JAva-第8章-ラッキー抽選-ログイン機能の実現
1511 ワード
import java.util.Scanner;
public class A01 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String admin = null,password = null,admin2,password2,choice2 = null;
int random = (int)(Math.random()*4000);
do{
Scanner input = new Scanner (System.in);
System.out.println("******* ********");
System.out.println("\t\t1. ");
System.out.println("\t\t2. ");
System.out.println("\t\t1. ");
System.out.println("*****************************");
System.out.println(" :");
int choice = input.nextInt();
switch (choice) {
case 1:
System.out.println(" > ");
System.out.println(" :");
admin = input.next();
System.out.println(" :");
password = input.next();
System.out.println(" , ");
System.out.println(" \t \t ");
System.out.println(admin+"\t"+password+"\t"+random);
break;
case 2:
System.out.println(" > ");
System.out.println(" :");
admin2=input.next();
System.out.println(" :");
password2=input.next();
if (admin.equals(admin2)&&password.equals(password2)){
System.out.println(" "+admin);
}else{
System.out.println(" !");
}
}
System.out.println(" (y / n):");
choice2=input.next();
}while(choice2.equals("y"));
System.out.println("
!");
}
}