desislava_topuzakova

04. Personal Titles

Sep 25th, 2021
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 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();
  8. //проверка за пола
  9. if (gender.equals("m")) {
  10. //мъж
  11. //проверка за възраст
  12. if (age >= 16) {
  13. System.out.println("Mr.");
  14. } else {
  15. System.out.println("Master");
  16. }
  17. } else if (gender.equals("f")) {
  18. //жена
  19. //проверка за възрастта
  20. if (age >= 16) {
  21. System.out.println("Ms.");
  22. } else {
  23. System.out.println("Miss");
  24. }
  25. }
  26. }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment