2017년 10월 27일 금요일

Java 숫자 추측 게임

import java.util.Scanner;

// LAB 숫자 추측 게임
public class Test01 {

public static void main(String[] args) {
int answer = (int)(Math.random()*100)+1;
int guess;
int cnt = 0;

Scanner sc = new Scanner(System.in);

do {
System.out.print("정답을 추측하여 보시오: ");
guess = sc.nextInt();
cnt++;

if (guess > answer)
System.out.println("제시한 정수가 높습니다.");
if (guess < answer)
System.out.println("제시한 정수가 낮습니다.");

} while (guess != answer);

System.out.println("축하합니다. 시도횟수="+ cnt);

}

}

댓글 없음:

댓글 쓰기

시스템 보안

1. 내컴퓨터는 해킹이 당한적 있는가? 있다. 2. 컴퓨터를 하게되면 해킹을 당한다. 무엇을 이용해 해킹을 하는가? 인터넷이 가장 보편적. 사회적인 공격(주변인이 사전정보를 가지고 해킹) 3. 대응을 어떻게 해야하나? 보안프로...