Advertisement
KeepCoding

SchoolCampFixed

Dec 9th, 2017
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SchoolCamp02 {
  4.     private static String repeat(String str, int count) {
  5.         String result = "";
  6.         for (int i = 0; i < count; i++) {
  7.             result += str;
  8.         }
  9.         return result;
  10.     }
  11.  
  12.     public static void main(String[] args) {
  13.         Scanner console = new Scanner(System.in);
  14.  
  15.         String season = console.nextLine().toLowerCase();
  16.         String group = console.nextLine().toLowerCase();
  17.         double schuler = Double.parseDouble(console.nextLine());
  18.         double nights = Double.parseDouble(console.nextLine());
  19.         double price = 0;
  20.         double total = 0;
  21.  
  22.         String sport = "";
  23.         if (group.equals("boys") || group.equals("girls")) {
  24.             if (season.equals("summer")) {
  25.                 if (group.equals("boys")) {
  26.                     sport = "Football";
  27.                 } else if (group.equals("girls")) {
  28.                     sport = "Volleyball";
  29.                 }
  30.                 price = 15;
  31.                 total = schuler * price * nights;
  32.                 if (schuler >= 50) {
  33.                     total -= total * 0.5;
  34.                 } else if (schuler >= 20 && schuler < 50) {
  35.                     total -= total * 0.15;
  36.                 } else if (schuler >= 10 && schuler < 20) {
  37.                     total -= total * 0.05;
  38.                 }
  39.             } else if (season.equals("spring")) {
  40.                 if (group.equals("boys")) {
  41.                     sport = "Tennis";
  42.                 } else if (group.equals("girls")) {
  43.                     sport = "Athletics";
  44.                 }
  45.                 price = 7.2;
  46.                 total = schuler * price * nights;
  47.                 if (schuler >= 50) {
  48.                     total -= total * 0.5;
  49.                 } else if (schuler >= 20 && schuler < 50) {
  50.                     total -= total * 0.15;
  51.                 } else if (schuler >= 10 && schuler < 20) {
  52.                     total -= total * 0.05;
  53.                 }
  54.             } else if (season.equals("winter")) {
  55.                 if (group.equals("boys")) {
  56.                     sport = "Judo";
  57.                 } else if (group.equals("girls")) {
  58.                     sport = "Gymnastics";
  59.                 }
  60.                 price = 9.6;
  61.                 total = schuler * price * nights;
  62.                 if (schuler >= 50) {
  63.                     total -= total * 0.5;
  64.                 } else if (schuler >= 20 && schuler < 50) {
  65.                     total -= total * 0.15;
  66.                 } else if (schuler >= 10 && schuler < 20) {
  67.                     total -= total * 0.05;
  68.                 }
  69.             }
  70.         } else {
  71.             if (season.equals("winter")) {
  72.                 sport = "Ski";
  73.                 price = 10;
  74.                 total = schuler * price * nights;
  75.                 if (schuler >= 50) {
  76.                     total -= total * 0.5;
  77.                 } else if (schuler >= 20 && schuler < 50) {
  78.                     total -= total * 0.15;
  79.                 } else if (schuler >= 10 && schuler < 20) {
  80.                     total -= total * 0.05;
  81.                 }
  82.             } else if (season.equals("spring")) {
  83.                 sport = "Cycling";
  84.                 price = 9.5;
  85.                 total = schuler * price * nights;
  86.                 if (schuler >= 50) {
  87.                     total -= total * 0.5;
  88.                 } else if (schuler >= 20 && schuler < 50) {
  89.                     total -= total * 0.15;
  90.                 } else if (schuler >= 10 && schuler < 20) {
  91.                     total -= total * 0.05;
  92.                 }
  93.             } else if (season.equals("summer")) {
  94.                 sport = "Swimming";
  95.  
  96.                 price = 20;
  97.                 total = schuler * price * nights;
  98.                 if (schuler >= 50) {
  99.                     total -= total * 0.5;
  100.                 } else if (schuler >= 20 && schuler < 50) {
  101.                     total -= total * 0.15;
  102.                 } else if (schuler >= 10 && schuler < 20) {
  103.                     total -= total * 0.05;
  104.                 }
  105.             }
  106.  
  107.         }
  108.         System.out.printf("%s %.2f lv.", sport, total);
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement