Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Created January 9, 2017 12:15
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 mokomokohitsuzi/c03719cd2b3a24cc0a44bba40fb0cc0d to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/c03719cd2b3a24cc0a44bba40fb0cc0d to your computer and use it in GitHub Desktop.
新・明解Java入門 演習7-9
import java.util.Scanner;
public class En07_09 {
public static void main(String[] args) {
// メソッド読び出し
int n;
do {
n = readPlusInt();
} while (n <= 0);
// 返却されたか分かりづらいため、出力しておきます。
System.out.println(n);
}
static int readPlusInt() {
Scanner stdIn = new Scanner(System.in);
System.out.print("正の整数値:");
int readPlusInt = stdIn.nextInt();
return readPlusInt;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment