Advertisement
Spocoman

04. Transport Price

Aug 24th, 2024
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Objects;
  2. import java.util.Scanner;
  3.  
  4. public class TransportPrice {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int km = Integer.parseInt(scanner.nextLine());
  8.         String time = scanner.nextLine();
  9.         double price;
  10.  
  11.         if (km < 20) {
  12.             if (Objects.equals(time, "day")) {
  13.                 price = km * 0.79 + 0.7;
  14.             } else {
  15.                 price = km * 0.9 + 0.7;
  16.             }
  17.         } else if (km >= 100) {
  18.             price = km * 0.06;
  19.         } else {
  20.             price = km * 0.09;
  21.         }
  22.  
  23.         System.out.printf("%.2f\n",  price);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement