BubaLazi

p_CheapestTransport

Mar 12th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.lang.String;
  3.  
  4. public class CheapestTransport {
  5.     public static void main(String[] args) {
  6.         Scanner console = new Scanner(System.in);
  7.  
  8.         int kM = Integer.parseInt(console.nextLine());
  9.         String time = console.nextLine();
  10.  
  11.         double taxiDay = 0.79;
  12.         double taxiNight = 0.90;
  13.         double serviceFee = 0.70;
  14.         double bus = 0.09;
  15.         double train =  0.06;
  16.         double cheapestTransport = 0;
  17.  
  18.         if(kM <= 20){
  19.             if(time.equals("day")){
  20.                 cheapestTransport = kM * taxiDay + serviceFee;
  21.                 System.out.printf("taxi: %.2f", cheapestTransport);
  22.             }else{
  23.                 cheapestTransport = kM * taxiNight +serviceFee;
  24.                 System.out.printf("taxi: %.2f", cheapestTransport);
  25.             }
  26.         }else if(kM > 20 && kM <= 100){
  27.             cheapestTransport = kM * bus;
  28.             System.out.printf("bus: %.2f", cheapestTransport);
  29.         }else if(kM > 100){
  30.             cheapestTransport = kM * train;
  31.             System.out.printf("train: %.2f", cheapestTransport);
  32.         }
  33.  
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment