Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Journey {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String season = scanner.nextLine();
- String place = "";
- String region = "";
- double sum = 0;
- switch (season) {
- case "summer":
- place = "Camp";
- if (budget <= 100) {
- sum = 0.3 * budget;
- } else if (budget > 100 && budget <= 1000) {
- sum = 0.4 * budget;
- }
- break;
- case "winter":
- place = "Hotel";
- if (budget <= 100) {
- sum = 0.7 * budget;
- } else if (budget > 100 && budget <= 1000) {
- sum = 0.8 * budget;
- }
- break;
- }
- if (budget <= 100) {
- region = "Bulgaria";
- } else if (budget > 100 && budget <= 1000) {
- region = "Balkans";
- } else {
- place = "Hotel";
- region = "Europe";
- sum = 0.9 * budget;
- }
- System.out.printf("Somewhere in %s\n%s - %.2f", region, place, sum);
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Journey {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String season = scanner.nextLine();
- String place = season.equals("summer") && budget <= 1000 ? "Camp" : "Hotel";
- String region = budget <= 100 ? "Bulgaria" : budget > 1000 ? "Europe" : "Balkans";
- budget *= budget <= 100 ? (season.equals("summer") ? 0.3 : 0.7)
- : budget > 100 && budget <= 1000 ? (season.equals("summer") ? 0.4 : 0.8) : 0.9;
- System.out.printf("Somewhere in %s\n%s - %.2f", region, place, budget);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement