奇数と偶数を三元演算子で判断する
- import java.util.Scanner;
-
-
- public class ParityCheck {
- public static void main(String[]args)
- {
- Scanner scanner = new Scanner(System.in);
- System.out.println(" ");
- long number = scanner.nextLong();
- String check = (number%2==0)?" : :":" : ";
- System.out.println(check);
- }
-
- }
note:%演算子の使用