Last active
August 29, 2015 14:13
-
-
Save d-kanazawa/75969ed1263200b42470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class kazuatefame { | |
public static void main(String[] args) { | |
String line =""; | |
int n =0; | |
int kai =0; | |
System.out.println("難易度を入力してください"); | |
String line1 = System.console().readLine(); | |
int Level=Integer.parseInt(line1); | |
switch (Level){ | |
case 1: | |
n = 30; | |
break; | |
case 2: | |
n = 20; | |
break; | |
case 3: | |
n = 10; | |
break; | |
} | |
System.out.printf("%d回以内に数字を当ててください%n",n); | |
int ran = (int)(Math.random()*50+1); | |
for(int i =1;i < n;i++){ | |
line = System.console().readLine(); | |
kai =Integer.parseInt(line); | |
if(kai ==ran){ | |
System.out.println("正解です"); | |
break; | |
}if(kai <ran){ | |
System.out.println("小さいです"); | |
}if(kai > ran){ | |
System.out.println("大きいです"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment