Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int juniorCount = Integer.parseInt(scanner.nextLine());
- int seniorCount = Integer.parseInt(scanner.nextLine());
- String trace = scanner.nextLine();
- double juniorPrice = 0, seniorPrice = 0;
- switch (trace) {
- case "trail" -> {
- juniorPrice = 5.50;
- seniorPrice = 7.00;
- }
- case "cross-country" -> {
- juniorPrice = 8.00;
- seniorPrice = 9.50;
- }
- case "downhill" -> {
- juniorPrice = 12.25;
- seniorPrice = 13.75;
- }
- case "road" -> {
- juniorPrice = 20.00;
- seniorPrice = 21.50;
- }
- }
- double sum = juniorPrice * juniorCount + seniorPrice * seniorCount;
- if (trace.equals("cross-country") && juniorCount + seniorCount >= 50) {
- sum *= 0.75;
- }
- System.out.printf("%.2f\n", sum * 0.95);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement