Advertisement
desislava_topuzakova

04. Personal Titles

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