Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Last active October 18, 2016 14:17
Show Gist options
  • Save mokomokohitsuzi/06b497e5554c7339029603a4896a7d8e to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/06b497e5554c7339029603a4896a7d8e to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-10
import java.util.Scanner;
public class En3_10 {
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();
// 三項演算子で結果を表示。
System.out.println("2つの整数値の差は" + (a > b ? (a - b) : (b - a)) + "です。");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment