galinyotsev123

ProgBasicsJavaBook4.1ComplexConditions01PersonalTitles

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