Advertisement
veronikaaa86

04. Personal Titles

Mar 12th, 2022
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package advancedConditionalStatements;
  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("m")) {
  13. if (age >= 16) {
  14. System.out.println("Mr.");
  15. } else if (age < 16) {
  16. System.out.println("Master");
  17. }
  18. } else if (gender.equals("f")) {
  19. if (age >= 16) {
  20. System.out.println("Ms.");
  21. } else {
  22. System.out.println("Miss");
  23. }
  24. }
  25. }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement