Advertisement
Spocoman

02. Summer Outfit

Aug 25th, 2024
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.95 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SummerOutfit {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int gradus = Integer.parseInt(scanner.nextLine());
  7.         String time = scanner.nextLine();
  8.  
  9.         String outfit = "Shirt";
  10.         String shoes = "Moccasins";
  11.  
  12.         if (time.equals("Morning")) {
  13.             if (gradus >= 10 && gradus <= 18) {
  14.                 outfit = "Sweatshirt";
  15.                 shoes = "Sneakers";
  16.             } else if (gradus > 24) {
  17.                 outfit = "T-Shirt";
  18.                 shoes = "Sandals";
  19.             }
  20.         } else if (time.equals("Afternoon")) {
  21.             if (gradus > 18 && gradus <= 24) {
  22.                 outfit = "T-Shirt";
  23.                 shoes = "Sandals";
  24.             } else if (gradus > 24) {
  25.                 outfit = "Swim Suit";
  26.                 shoes = "Barefoot";
  27.             }
  28.         }
  29.  
  30.         System.out.printf("It's %d degrees, get your %s and %s.", gradus, outfit, shoes);
  31.     }
  32. }
  33.  
  34. ИЛИ:
  35.  
  36. import java.util.Scanner;
  37.  
  38. public class SummerOutfit {
  39.     public static void main(String[] args) {
  40.         Scanner scanner = new Scanner(System.in);
  41.         int gradus = Integer.parseInt(scanner.nextLine());
  42.         String time = scanner.nextLine();
  43.  
  44.         String outfit =
  45.                 time.equals("Morning") ? (gradus >= 10 && gradus <= 18 ? "Sweatshirt" : gradus > 24 ? "T-Shirt" : "Shirt") :
  46.                 time.equals("Afternoon") ? (gradus > 18 && gradus <= 24 ? "T-Shirt" : gradus > 24 ? "Swim Suit" : "Shirt") : "Shirt";
  47.  
  48.         String shoes =
  49.                 time.equals("Morning") ? (gradus >= 10 && gradus <= 18 ? "Sneakers" : gradus > 24 ? "Sandals" : "Moccasins") :
  50.                 time.equals("Afternoon") ? (gradus > 18 && gradus <= 24 ? "Sandals" : gradus > 24 ? "Barefoot" : "Moccasins") : "Moccasins";
  51.  
  52.         System.out.printf("It's %d degrees, get your %s and %s.", gradus, outfit, shoes);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement