Skip to content

Instantly share code, notes, and snippets.

@mokomokohitsuzi
Created October 11, 2016 11:44
Show Gist options
  • Save mokomokohitsuzi/4a4d40d2e89e4047870254931986f674 to your computer and use it in GitHub Desktop.
Save mokomokohitsuzi/4a4d40d2e89e4047870254931986f674 to your computer and use it in GitHub Desktop.
新・明解Java入門 演習3-4
import java.util.Scanner;
public class En3_4 {
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();
//aとbを比べ、条件によって分岐する。
if (a > b) {
System.out.println("aのほうが大きいです。");
} else if (b > a) {
System.out.println("bのほうが大きいです。");
} else {
System.out.println("aとbは同じ値です。");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment