Valeri173

Cena za Transport

Jan 22nd, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main16 {
  4.     public static void main(String[] args){
  5.         Scanner scan = new Scanner(System.in);
  6.         int distance = Integer.parseInt(scan.nextLine());
  7.         String dayOrNight = scan.nextLine();
  8.         double price = 0.0d;
  9.         double taxiRate = 0.0d;
  10.  
  11.         if(dayOrNight.equals("day")){
  12.             taxiRate = 0.79;
  13.         } else if(dayOrNight.equals("night")){
  14.             taxiRate = 0.90;
  15.         }
  16.  
  17.         if(distance < 20){
  18.             price = 0.70 + (distance * taxiRate);
  19.         } else if(distance < 100){
  20.             price = distance * 0.09;
  21.         } else {
  22.             price = distance * 0.06;
  23.         }
  24.  
  25.         System.out.println(price);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment