Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SchoolCamp {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String season = scanner.nextLine();
- String group = scanner.nextLine();
- int people = Integer.parseInt(scanner.nextLine());
- int nights = Integer.parseInt(scanner.nextLine());
- double price = 0;
- String sport = "";
- if (season.equals("Winter")) {
- switch (group) {
- case "boys":
- price = 9.60;
- sport = "Judo";
- break;
- case "girls":
- price = 9.60;
- sport ="Gymnastics";
- break;
- case "mixed":
- price = 10.00;
- sport = "Ski";
- break;
- }
- } else if (season.equals("Spring")) {
- switch (group) {
- case "boys":
- price = 7.20;
- sport = "Tennis";
- break;
- case "girls":
- price = 7.20;
- sport = "Athletics";
- break;
- case "mixed":
- price = 9.50;
- sport = "Cycling";
- break;
- }
- } else {
- switch (group) {
- case "boys":
- price = 15.00;
- sport = "Football";
- break;
- case "girls":
- price = 15.00;
- sport = "Volleyball";
- break;
- case "mixed":
- price = 20.00;
- sport = "Swimming";
- break;
- }
- }
- if (people >= 50) {
- price *= 0.50;
- } else if (people >= 20) {
- price *= 0.85;
- } else if (people >= 10) {
- price *= 0.95;
- }
- double totalSum = price * people * nights;
- System.out.printf(" %s %.2f lv.\n", sport, totalSum);
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class SchoolCamp {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String season = scanner.nextLine();
- String group = scanner.nextLine();
- int people = Integer.parseInt(scanner.nextLine());
- int nights = Integer.parseInt(scanner.nextLine());
- double price = 0;
- String sport = "";
- if (season.equals("Winter")) {
- price = group.equals("boys") ? 9.60 : group.equals("girls") ? 9.60 : 10.00;
- sport = group.equals("boys") ? "Judo" : group.equals("girls") ? "Gymnastics" : "Ski";
- } else if (season.equals("Spring")) {
- price = group.equals("boys") ? 7.20 : group.equals("girls") ? 7.20 : 9.50;
- sport = group.equals("boys") ? "Tennis" : group.equals("girls") ? "Athletics" : "Cycling";
- } else {
- price = group.equals("boys") ? 15.00 : group.equals("girls") ? 15.00 : 20.00;
- sport = group.equals("boys") ? "Football" : group.equals("girls") ? "Volleyball" : "Swimming";
- }
- price *=
- people >= 50 ? 0.50 :
- people >= 20 ? 0.85 :
- people >= 10 ? 0.95 : 1;
- double totalSum = price * people * nights;
- System.out.printf(" %s %.2f lv.\n", sport, totalSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement