Advertisement
SRomanova

BikeRace

May 24th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BikeRace {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int juniorParticipant = Integer.parseInt(scanner.nextLine());
  7.         int seniorParticipant = Integer.parseInt(scanner.nextLine());
  8.         String race = scanner.nextLine();
  9.         double collectedSum = 0;
  10.  
  11.         if(race.equals("trail")){
  12.            collectedSum = juniorParticipant*5.5+seniorParticipant*7.0;
  13.         }else if(race.equals("cross-country")){
  14.             collectedSum = juniorParticipant*8.0+seniorParticipant*9.5;
  15.             if(juniorParticipant+seniorParticipant>=50){
  16.                 collectedSum = collectedSum*0.75;
  17.             }
  18.         }else if(race.equals("downhill")){
  19.             collectedSum = juniorParticipant*12.25+seniorParticipant*13.75;
  20.         }else {
  21.             collectedSum = juniorParticipant*20.0+seniorParticipant*21.50;
  22.         }
  23.         collectedSum = collectedSum*.95;
  24.         System.out.printf("%.2f",collectedSum);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement