Advertisement
SensaBG

Untitled

Jun 16th, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class test {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double price = 0;
  8.         String season = scanner.nextLine();
  9.         String studentsGroup = scanner.nextLine();
  10.         int studentsNumber = Integer.parseInt(scanner.nextLine());
  11.         int nightsStand = Integer.parseInt(scanner.nextLine());
  12.  
  13.         switch (season) {
  14.             case "Spring" -> {
  15.                 if (studentsGroup.equals("girls") || studentsGroup.equals("boys")) {
  16.                     price = 7.20;
  17.                 } else if (studentsGroup.equals("mixed")) {
  18.                     price = 9.50;
  19.                 }
  20.             }
  21.             case "Winter" -> {
  22.                 if (studentsGroup.equals("girls") || studentsGroup.equals("boys")) {
  23.                     price = 9.60;
  24.                 } else if (studentsGroup.equals("mixed")) {
  25.                     price = 10.0;
  26.                 }
  27.             }
  28.             case "Summer" -> {
  29.                 if (studentsGroup.equals("girls") || studentsGroup.equals("boys")) {
  30.                     price = 15.0;
  31.                 } else if (studentsGroup.equals("mixed")) {
  32.                     price = 20.0;
  33.                 }
  34.             }
  35.         }
  36.  
  37.         price = nightsStand * studentsNumber * price;
  38.  
  39.         if (studentsNumber >= 50) {
  40.             price *= 0.50;
  41.         } else if (studentsNumber >= 20) {
  42.             price *= 0.15;
  43.         } else if (studentsNumber >= 10) {
  44.              price *= 0.05;
  45.         }
  46.        
  47.         String activity = "";
  48.         switch (studentsGroup) {
  49.             case "girls" -> {
  50.                 switch (season) {
  51.                     case "Winter" -> activity = "Gymnastics";
  52.                     case "Spring" -> activity = "Athletics";
  53.                     case "Summer" -> activity = "Volleyball";
  54.  
  55.                 }
  56.             }
  57.             case "boys" -> {
  58.                 switch (season) {
  59.                     case "Winter" -> activity = "Judo";
  60.                     case "Spring" -> activity = "Tennis";
  61.                     case "Summer" -> activity = "Football";
  62.  
  63.                 }
  64.             }
  65.             case "mixed" -> {
  66.                 switch (season) {
  67.                     case "Winter" -> activity = "Ski";
  68.                     case "Spring" -> activity = "Cycling";
  69.                     case "Summer" -> activity = "Swimming";
  70.                 }
  71.             }
  72.         }
  73.         System.out.printf("%s %.2f lv.", activity, price);
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement