Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active October 16, 2016 05:04
Show Gist options
  • Save mokomokohitsuzi/59fb406d0f94a76ce1d9df1342a45fc9 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/59fb406d0f94a76ce1d9df1342a45fc9 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-6
import java.util.Scanner;
public class En3_6 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("正の整数値:");
int n = stdIn.nextInt();
if (n <= 0) {
// 負の値の時に表示
System.out.println("正でない値が入力されました。");
} else if (n % 10 == 0) {
// 10で割った余りが0の場合は、10の倍数となる。
System.out.println("その値は10の倍数です。");
} else if (n % 10 != 0) {
// 10で割った余りが0以外の場合は、10の倍数では無い。
System.out.println("その値は10の倍数ではありません。");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment