SHARE
TWEET

Transport price

16120 Dec 16th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class transportm {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int distance = Integer.parseInt(scanner.nextLine());
  8.         String dayOrNight = scanner.nextLine();
  9.         double price = 0.0d;
  10.         double taxiRate = 0.0d;
  11.  
  12.         if (dayOrNight.equals("day")) {
  13.             taxiRate = 0.79;
  14.         } else if (dayOrNight.equals("night")) {
  15.             taxiRate = 0.90;
  16.  
  17.         }
  18.  
  19.         if (distance < 20) {
  20.             price = 0.70 + (distance * taxiRate);
  21.         } else if (distance < 100) {
  22.             price = distance * 0.09;
  23.         } else {
  24.             price = distance * 0.06;
  25.         }
  26.         System.out.println(price);
  27.  
  28.     }
  29. }
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