SHARE
TWEET

BikeRace

SRomanova May 24th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top