Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active October 19, 2016 13:02
Show Gist options
  • Save mokomokohitsuzi/b7a6089e6e14a4ed8ccca12c5d56c639 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/b7a6089e6e14a4ed8ccca12c5d56c639 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-11
import java.util.Scanner;
public class En3_11 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
System.out.print("整数A:");
int a = stdIn.nextInt();
System.out.print("整数B:");
int b = stdIn.nextInt();
// 差を求める 差が10以下である場合、それ以上の場合。
int sa = (a > b ? a - b : b - a);
System.out.println("それらの差は10" + (sa <= 10 ? "以下" : "以上") + "です。");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment