Created
October 12, 2016 14:27
-
-
Save mokomokohitsuzi/ccfffa5b18d70d3c10307b342012af39 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-5
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 En3_5 { | |
public static void main(String[] args) { | |
Scanner stdIn = new Scanner(System.in); | |
System.out.print("正の整数値:"); | |
int n = stdIn.nextInt(); | |
if (n <= 0) { | |
// nが負の値の場合 | |
System.out.println("正でない値が入力されました。"); | |
} else if (n % 5 == 0) { | |
// nの値が5で割り切れる場合 | |
System.out.println("その値は5で割り切れます。"); | |
} else if (n % 5 != 0) { | |
// nの値が5で割り切れない場合 | |
System.out.println("その値は5で割り切れません。"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment