//★運試しゲーム★1~10までの数字を予想しよう。
import java.io.*;
public class repo3 {
public static void main(String[] args) throws IOException {
//標準入力の準備
BufferedReader buf = new BufferedReader(new
InputStreamReader(System.in));
int next; //コンピュータの次の数値
int guess; //ユーザの予想
while(true){ //
next = (int)(Math.random()*10 +1); //乱数の範囲を1~10までに制限
System.out.print("Your guess : ");
guess = Integer.parseInt(buf.readLine()); //入力を標準入力より取得
System.out.println("correct number: " + next); //乱数の表示
if(next != guess){
System.out.println("guess again"); //はずれ
}else{
System.out.println("Bingo!!"); //あたり
break; //あたりのときbreakする
}
}//whileに戻る
} //mainの終り
} //class repo3 の終り
|