Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BikeRace {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int juniorParticipant = Integer.parseInt(scanner.nextLine());
- int seniorParticipant = Integer.parseInt(scanner.nextLine());
- String race = scanner.nextLine();
- double collectedSum = 0;
- if(race.equals("trail")){
- collectedSum = juniorParticipant*5.5+seniorParticipant*7.0;
- }else if(race.equals("cross-country")){
- collectedSum = juniorParticipant*8.0+seniorParticipant*9.5;
- if(juniorParticipant+seniorParticipant>=50){
- collectedSum = collectedSum*0.75;
- }
- }else if(race.equals("downhill")){
- collectedSum = juniorParticipant*12.25+seniorParticipant*13.75;
- }else {
- collectedSum = juniorParticipant*20.0+seniorParticipant*21.50;
- }
- collectedSum = collectedSum*.95;
- System.out.printf("%.2f",collectedSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement