veronikaaa86

04. Personal Titles

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