Created
January 9, 2017 12:15
-
-
Save mokomokohitsuzi/c03719cd2b3a24cc0a44bba40fb0cc0d to your computer and use it in GitHub Desktop.
新・明解Java入門 演習7-9
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.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