Created
January 20, 2015 03:37
-
-
Save komo91/eed8bbd4af90f8294000 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
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