Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Created October 28, 2016 14:12
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/a57cedc95aae32c50099c2617ea5a70b to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/a57cedc95aae32c50099c2617ea5a70b to your computer and use it in GitHub Desktop.
新・明解Java入門 演習4-4
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