Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int x = scanner.next().charAt(0);
- if (x > 64 && x < 91) {
- System.out.println("upper-case");
- } else if (x > 96 && x < 123) {
- System.out.println("lower-case");
- }
- }
- }
- Solutions with methods:
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char x = scanner.nextLine().charAt(0);
- if (Character.isUpperCase(x)) {
- System.out.println("upper-case");
- } else if (Character.isLowerCase(x)) {
- System.out.println("lower-case");
- }
- }
- }
- Solution with methods and ternary operator:
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char x = scanner.nextLine().charAt(0);
- System.out.println(Character.isUpperCase(x) ? "upper-case": "lower-case");
- }
- }
- Or:
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println(Character.isUpperCase(scanner.nextLine().charAt(0)) ? "upper-case": "lower-case");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement