Advertisement
Spocoman

Cat Life

Sep 2nd, 2024
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String catBreed = scanner.nextLine(),
  7.                 catGender = scanner.nextLine();
  8.  
  9.         int breedYears = switch (catBreed) {
  10.             case "Siberian" -> 11;
  11.             case "American Shorthair" -> 12;
  12.             case "British Shorthair" -> 13;
  13.             case "Persian" -> 14;
  14.             case "Siamese" -> 15;
  15.             case "Ragdoll" -> 16;
  16.         };
  17.  
  18.         if (catGender.equals("f")) {
  19.             breedYears++;
  20.         }
  21.  
  22.         if (breedYears > 0) {
  23.             System.out.printf("%d cat months", breedYears * 2);
  24.         } else {
  25.             Scanner.out.printf("%s is invalid cat!", catBreed);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement