Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PriceforTransport {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int Kmcount = Integer.parseInt(scanner.nextLine());
  7.         String dayornight = (scanner.nextLine());
  8.  
  9.         double TaxiprizeStart = 0.70;
  10.         double TaxiprizeDay = 0.79;
  11.         double TaxiprizeNight = 0.90;
  12.         double BusPrize = 0.09;
  13.         double TrainPrize = 0.06;
  14.         double DayTotalWithTaxi = TaxiprizeStart + Kmcount * TaxiprizeDay;
  15.         double NightTotalWithTaxi = TaxiprizeStart + Kmcount * TaxiprizeNight;
  16.         double TotalWithBus = Kmcount * BusPrize;
  17.         double TotalWithTrain = Kmcount * TrainPrize;
  18.         if ( Kmcount < 20 && dayornight.equalsIgnoreCase("day")){
  19.             System.out.printf("%.2f", DayTotalWithTaxi);
  20.         }
  21.         else if ( Kmcount < 20 && dayornight.equalsIgnoreCase("night")){
  22.             System.out.printf("%.2f", NightTotalWithTaxi);
  23.  
  24.         } else if (Kmcount >= 20 && Kmcount < 100 ){
  25.             System.out.printf("%.2f", TotalWithBus);
  26.         } else if (Kmcount > 100){
  27.             System.out.printf("%.2f", TotalWithTrain);
  28.         }
  29.  
  30.  
  31.  
  32.  
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement