Last active
October 6, 2016 12:11
-
-
Save mokomokohitsuzi/d114366d2ccb3bcd7e22298ff9b19e36 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習2-8
This file contains 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; | |
import java.util.Scanner; | |
public class En2_8 { | |
public static void main(String[] args) { | |
Random rand = new Random(); | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("整数値:"); | |
int seisu = stdIn.nextInt(); | |
//-5~5までの乱数を生成。 | |
int ransu = rand.nextInt(11) - 5; | |
System.out.print("その値の±5の乱数を生成しました。"); | |
System.out.print("それは" + (seisu + ransu) + "です。"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment