Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SummerOutfit {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int gradus = Integer.parseInt(scanner.nextLine());
- String time = scanner.nextLine();
- String outfit = "Shirt";
- String shoes = "Moccasins";
- if (time.equals("Morning")) {
- if (gradus >= 10 && gradus <= 18) {
- outfit = "Sweatshirt";
- shoes = "Sneakers";
- } else if (gradus > 24) {
- outfit = "T-Shirt";
- shoes = "Sandals";
- }
- } else if (time.equals("Afternoon")) {
- if (gradus > 18 && gradus <= 24) {
- outfit = "T-Shirt";
- shoes = "Sandals";
- } else if (gradus > 24) {
- outfit = "Swim Suit";
- shoes = "Barefoot";
- }
- }
- System.out.printf("It's %d degrees, get your %s and %s.", gradus, outfit, shoes);
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class SummerOutfit {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int gradus = Integer.parseInt(scanner.nextLine());
- String time = scanner.nextLine();
- String outfit =
- time.equals("Morning") ? (gradus >= 10 && gradus <= 18 ? "Sweatshirt" : gradus > 24 ? "T-Shirt" : "Shirt") :
- time.equals("Afternoon") ? (gradus > 18 && gradus <= 24 ? "T-Shirt" : gradus > 24 ? "Swim Suit" : "Shirt") : "Shirt";
- String shoes =
- time.equals("Morning") ? (gradus >= 10 && gradus <= 18 ? "Sneakers" : gradus > 24 ? "Sandals" : "Moccasins") :
- time.equals("Afternoon") ? (gradus > 18 && gradus <= 24 ? "Sandals" : gradus > 24 ? "Barefoot" : "Moccasins") : "Moccasins";
- System.out.printf("It's %d degrees, get your %s and %s.", gradus, outfit, shoes);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement