Advertisement
CR7CR7

TransportPrice

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