Skip to content

Instantly share code, notes, and snippets.

@komo91
Created January 20, 2015 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komo91/eed8bbd4af90f8294000 to your computer and use it in GitHub Desktop.
Save komo91/eed8bbd4af90f8294000 to your computer and use it in GitHub Desktop.
import java.util.Random;
public class Omikuzi1 {
public static void main(String[] args) {
Random rn = new Random();
int a = rn.nextInt(100)+1;
int b = rn.nextInt(100)+1;
int c;
System.out.println("何が出るか!?");
//cをマイナスにしないためif文で式を変える
if(a<b) {
c = b-a;
} else {
c = a-b;
}
//if文結果を表示
System.out.println(c);
//おみくじの結果を表示
//差が0なら大吉、1~10なら吉、11~50なら吉、51~100なら大凶
if(c == 0) {
System.out.println("大吉です!\n今年は良いことあるかも…");
} else if(c <= 10) {
System.out.println("吉です!\nまあ普通ですね。良くも悪くもない…");
} else if(c > 10 && c <= 50) {
System.out.println("凶です!\nまあ何が起こるか分からないので気を付けよう…");
} else {
System.out.println("大凶です!\n……ドンマイ……");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment