Skip to content

Instantly share code, notes, and snippets.

Avatar

mokomokohitsuzi

View GitHub Profile
@mokomokohitsuzi
mokomokohitsuzi / En07_17.java
Created Jan 16, 2017
新・明解Java入門 演習7-17
View En07_17.java
import java.util.Scanner;
public class En07_17 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("要素数:");
int num = stdIn.nextInt();
int[] x = new int[num];
@mokomokohitsuzi
mokomokohitsuzi / En07_16.java
Created Jan 14, 2017
新・明解Java入門 演習7-16
View En07_16.java
import java.util.Random;
import java.util.Scanner;
public class En07_16 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
Random rand = new Random();
System.out.print("配列aの要素数:");
@mokomokohitsuzi
mokomokohitsuzi / En07_15.java
Created Jan 12, 2017
新・明解Java入門 演習7-15
View En07_15.java
import java.util.Random;
import java.util.Scanner;
public class En07_15 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
Random rand = new Random();
System.out.print("配列aの要素数:");
@mokomokohitsuzi
mokomokohitsuzi / En07_10.java
Created Jan 9, 2017
新・明解Java入門 演習7-10
View En07_10.java
import java.util.Random;
import java.util.Scanner;
public class En07_10 {
static Scanner stdIn = new Scanner(System.in);
public static void main(String[] args) {
Random rand = new Random();
@mokomokohitsuzi
mokomokohitsuzi / En07_09.java
Created Jan 9, 2017
新・明解Java入門 演習7-9
View En07_09.java
import java.util.Scanner;
public class En07_09 {
public static void main(String[] args) {
// メソッド読び出し
int n;
do {
n = readPlusInt();
} while (n <= 0);
@mokomokohitsuzi
mokomokohitsuzi / En07_08.java
Last active Jan 7, 2017
新・明解Java入門 演習7-8
View En07_08.java
/*
* a以上b未満の乱数を生成して、その値を返却するメソッド【int random(int a,int b)】を
* 作成せよ。内部で乱数を生成する標準ライブラリを呼び出すこと。
* なお、bの値がaより小さい場合には、aの値をそのまま返却すること。
*/
package hukusyuu.en07;
import java.util.Random;
import java.util.Scanner;
@mokomokohitsuzi
mokomokohitsuzi / En07_07.java
Created Jan 4, 2017
新・明解Java入門 演習7-7
View En07_07.java
import java.util.Scanner;
public class En07_07 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("左下直角の直角三角形を表示します");
System.out.print("段数は:");
int n = stdIn.nextInt();
@mokomokohitsuzi
mokomokohitsuzi / En07_06.java
Created Dec 28, 2016
新・明解Java入門 演習7-6
View En07_06.java
import java.util.Scanner;
public class En07_06 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("季節を表示します。");
System.out.print("月を入力して下さい。:");
int m = stdIn.nextInt();
@mokomokohitsuzi
mokomokohitsuzi / En07_05.java
Created Dec 27, 2016
新・明解Java入門 演習7-5
View En07_05.java
public class En07_05 {
public static void main(String[] args) {
hello();
}
// System.out.printlnで表示するメソッド
static void hello() {
System.out.println("こんにちは。");
@mokomokohitsuzi
mokomokohitsuzi / En07_04.java
Created Dec 26, 2016
新・明解Java入門 演習7-4
View En07_04.java
import java.util.Scanner;
public class En07_04 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.println("1からnまでの全整数を加算します。");
int n;
do {