YavorGrancharov

BikeRace

Mar 4th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BikeRace {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int juniors = Integer.parseInt(console.nextLine());
  7.         int seniors = Integer.parseInt(console.nextLine());
  8.         String trace = console.nextLine();
  9.  
  10.         if (trace.equals("trail")) {
  11.             double tax = (juniors * 5.50) + (seniors * 7);
  12.             double expenses = tax - (tax * 0.05);
  13.             System.out.printf("%.2f", expenses);
  14.         } else if (trace.equals("cross-country") && (juniors + seniors) < 50) {
  15.             double tax = (juniors * 8) + (seniors * 9.50);
  16.             double expences = tax - (tax * 0.05);
  17.             System.out.printf("%.2f", expences);
  18.         } else if (trace.equals("downhill")) {
  19.             double tax = (juniors * 12.25) + (seniors * 13.75);
  20.             double expenses = tax - (tax * 0.05);
  21.             System.out.printf("%.2f", expenses);
  22.         } else if (trace.equals("road")) {
  23.             double tax = (juniors * 20) + (seniors * 21.50);
  24.             double expences = tax - (tax * 0.05);
  25.             System.out.printf("%.2f", expences);
  26.         }
  27.  
  28.         if (trace.equals("cross-country") && (juniors + seniors) >= 50) {
  29.             double tax = (juniors * 6) + (seniors * 7.125);
  30.             double expences = tax - (tax * 0.05);
  31.             System.out.printf("%.2f", expences);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment