Created
October 28, 2016 14:12
-
-
Save mokomokohitsuzi/a57cedc95aae32c50099c2617ea5a70b to your computer and use it in GitHub Desktop.
新・明解Java入門 演習4-4
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 En4_4 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.println("カウントダウンします。"); | |
int x; | |
do { | |
System.out.print("正の整数値:"); | |
x = stdIn.nextInt(); | |
} while (x <= 0);// xが0以下の場合、ループする。 | |
while (x >= 0) {// xが0以上の場合、繰り返す。 | |
System.out.println(x); | |
x--;// xを-1する。 | |
} | |
System.out.println("xの実際の値は" + x + "です。"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment