import java.util.*;
public class lab2_2 {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int use;
int com = (int)(Math.random()*3)+1;
/*
* com = 1 가위
* com = 2 바위
* com = 3 보
*/
System.out.println("==============================");
System.out.println(" 학번 : 201403010");
System.out.println(" 이름 : 김지하");
System.out.println("==============================");
System.out.println();
System.out.print("1. 가위/ 2. 바위/ 3. 보 : ");
use = sc.nextInt();
if(use>0 && use<4)//1~3까지만 받기 위해서
{
switch(use)//당신이 입력한 값
{
case 1:
if(use -com == 0)
System.out.println("무승부");
else if(use - com == -1)
System.out.println("당신이 졌습니다.");
else
System.out.println("당신이 이겼습니다.");
case 2:
if(use -com == 0)
System.out.println("무승부");
else if(use - com == -1)
System.out.println("당신이 졌습니다.");
else
System.out.println("당신이 이겼습니다.");
break;
case 3:
if(use -com == 0)
System.out.println("무승부");
else if(use - com == 2)
System.out.println("당신이 졌습니다.");
else
System.out.println("당신이 이겼습니다.");
break;
}
if(com == 1)
System.out.println("컴퓨터는 가위를 냈습니다.");
else if(com == 2)
System.out.println("컴퓨터는 바위를 냈습니다.");
else
System.out.println("컴퓨터는 보를 냈습니다.");
}
else{
System.out.println("잘 못입력하였습니다.");
}
}
}
실행 화면 1
실행 화면 2