Advertisement
psi_mmobile

Untitled

Apr 18th, 2022
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         int minCabRange = 0;
  4.         int minBusRange = 20;
  5.         int minTrainRange = 100;
  6.        
  7.         double baseCabTax = 0.70;
  8.         double dayCabTaxPerKm = 0.79;
  9.         double nightCabTaxPerKm = 0.90;
  10.        
  11.         double busTaxPerKm = 0.09;
  12.         double trainTaxPerKm = 0.06;
  13.        
  14.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  15.         int kilometers = scanner.nextInt();
  16.        
  17.         String tariff = scanner.next();
  18.        
  19.         double smallest = 0.0;
  20.        
  21.         if (kilometers < 20) {
  22.             if (tariff.equalsIgnoreCase("day")) {
  23.                 smallest = baseCabTax + kilometers * dayCabTaxPerKm;
  24.             }
  25.             if (tariff.equalsIgnoreCase("night")) {
  26.                 smallest = baseCabTax + kilometers * nightCabTaxPerKm;
  27.             }
  28.         }
  29.         if (kilometers >= 20 && kilometers < 100) {
  30.             smallest = kilometers * busTaxPerKm;
  31.         }
  32.        
  33.         if (kilometers >= 100) {
  34.             smallest = kilometers * trainTaxPerKm;
  35.         }
  36.        
  37.         System.out.print(smallest);
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement