Advertisement
BubaLazi

CheapestTransport

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