Advertisement
veronikaaa86

04. Personal Titles

Jan 21st, 2023
940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. package nestedConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P04PersonalTitles {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double age = Double.parseDouble(scanner.nextLine());
  10.         String gender = scanner.nextLine();
  11.  
  12.         if (gender.equals("f")) {
  13.             if (age >= 16) {
  14.                 System.out.println("Ms.");
  15.             } else if (age < 16) {
  16.                 System.out.println("Miss");
  17.             }
  18.         } else if (gender.equals("m")) {
  19.             if (age >= 16) {
  20.                 System.out.println("Mr.");
  21.             } else if (age < 16) {
  22.                 System.out.println("Master");
  23.             }
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement