Advertisement
Spocoman

Bike Race

Sep 1st, 2024
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int juniorCount = Integer.parseInt(scanner.nextLine());
  7.         int seniorCount = Integer.parseInt(scanner.nextLine());
  8.         String trace = scanner.nextLine();
  9.         double juniorPrice = 0, seniorPrice = 0;
  10.  
  11.         switch (trace) {
  12.             case "trail" -> {
  13.                 juniorPrice = 5.50;
  14.                 seniorPrice = 7.00;
  15.             }
  16.             case "cross-country" -> {
  17.                 juniorPrice = 8.00;
  18.                 seniorPrice = 9.50;
  19.             }
  20.             case "downhill" -> {
  21.                 juniorPrice = 12.25;
  22.                 seniorPrice = 13.75;
  23.             }
  24.             case "road" -> {
  25.                 juniorPrice = 20.00;
  26.                 seniorPrice = 21.50;
  27.             }
  28.         }
  29.  
  30.         double sum = juniorPrice * juniorCount + seniorPrice * seniorCount;
  31.  
  32.         if (trace.equals("cross-country") && juniorCount + seniorCount >= 50) {
  33.             sum *= 0.75;
  34.         }
  35.         System.out.printf("%.2f\n", sum * 0.95);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement