Advertisement
KeepCoding

SchoolCampMyVersion

Dec 9th, 2017
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SchoolCamp {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         String season = console.nextLine().toLowerCase();
  8.         String group = console.nextLine().toLowerCase();
  9.         int numberOfStudents = Integer.parseInt(console.nextLine());
  10.         int nightsSpent = Integer.parseInt(console.nextLine());
  11.  
  12.         double discount = 0;
  13.  
  14.         if (numberOfStudents >= 50) {
  15.             discount = 0.5;
  16.         } else if (numberOfStudents >= 20) {
  17.             discount = 0.15;
  18.         } else if (numberOfStudents >= 10) {
  19.             discount = 0.05;
  20.         }
  21.  
  22.         double pricePerNight = 0;
  23.         String sport = "";
  24.  
  25.         if (season.equals("winter")) {
  26.             if (group.equals("boys") || group.equals("girls")) {
  27.                 pricePerNight = 9.60;
  28.             } else if (group.equals("mixed")) {
  29.                 pricePerNight = 10.0;
  30.             }
  31.  
  32.             if (group.equals("boys")) {
  33.                 sport = "Judo";
  34.             } else if (group.equals("girls")) {
  35.                 sport = "Gymnastics";
  36.             } else if (group.equals("mixed")) {
  37.                 sport = "Ski";
  38.             }
  39.  
  40.  
  41.         } else if (season.equals("spring")) {
  42.             if (group.equals("boys") || group.equals("girls")) {
  43.                 pricePerNight = 7.20;
  44.             } else if (group.equals("mixed")) {
  45.                 pricePerNight = 9.50;
  46.             }
  47.  
  48.             if (group.equals("boys")) {
  49.                 sport = "Tennis";
  50.             } else if (group.equals("girls")) {
  51.                 sport = "Athletics";
  52.             } else if (group.equals("mixed")) {
  53.                 sport = "Cycling";
  54.             }
  55.  
  56.         } else if (season.equals("summer")) {
  57.             if (group.equals("boys") || group.equals("girls")) {
  58.                 pricePerNight = 15;
  59.             } else if (group.equals("mixed")) {
  60.                 pricePerNight = 20;
  61.             }
  62.  
  63.             if (group.equals("boys")) {
  64.                 sport = "Football";
  65.             } else if (group.equals("girls")) {
  66.                 sport = "Volleyball";
  67.             } else if (group.equals("mixed")) {
  68.                 sport = "Swimming";
  69.             }
  70.  
  71.         }
  72.  
  73.         double totalPrice = pricePerNight * nightsSpent * numberOfStudents;
  74.         totalPrice -= totalPrice * discount;
  75.  
  76.         System.out.printf("%s %.02f lv.", sport, totalPrice);
  77.  
  78.         // main ends here
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement