desislava_topuzakova

4. Обръщение според възраст и пол

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