Advertisement
Guest User

Untitled

a guest
May 18th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * https://judge.softuni.bg/Contests/Practice/Index/540#2
  5.  */
  6. public class Ex03SchoolCamp {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         String season = scanner.nextLine();
  11.         String groupType = scanner.nextLine();
  12.         int students = Integer.parseInt(scanner.nextLine());
  13.         int nights = Integer.parseInt(scanner.nextLine());
  14.         double cost;
  15.         String sport;
  16.  
  17.         switch (season) {
  18.             case "Winter": {
  19.                 if ("mixed".equals(groupType)) {
  20.                     cost = 10.0d;
  21.                     sport = "Ski";
  22.                 } else {
  23.                     cost = 9.6d;
  24.                     if ("boys".equals(groupType)) {
  25.                         sport = "Judo";
  26.                     } else {
  27.                         sport = "Gymnastics";
  28.                     }
  29.                 }
  30.             } break;
  31.             case "Spring": {
  32.                 if ("mixed".equals(groupType)) {
  33.                     cost = 9.5d;
  34.                     sport = "Cycling";
  35.                 } else {
  36.                     cost = 7.2d;
  37.                     if ("boys".equals(groupType)) {
  38.                         sport = "Tennis";
  39.                     } else {
  40.                         sport = "Athletics";
  41.                     }
  42.                 }
  43.             } break;
  44.             default: {
  45.                 if ("mixed".equals(groupType)) {
  46.                     cost = 20d;
  47.                     sport = "Swimming";
  48.                 } else {
  49.                     cost = 15d;
  50.                     if ("boys".equals(groupType)) {
  51.                         sport = "Football";
  52.                     } else {
  53.                         sport = "Volleyball";
  54.                     }
  55.                 }
  56.             } break;
  57.         }
  58.  
  59.         cost *= nights;
  60.         cost *= students;
  61.  
  62.         if (students >= 50) {
  63.             cost *= 0.5d;
  64.         } else if (students >= 20) {
  65.             cost *= 0.85d;
  66.         } else if (students >= 10) {
  67.             cost *= 0.95d;
  68.         }
  69.  
  70.         System.out.printf("%s %.2f lv.", sport, cost);
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement