Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PriceforTransport {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int Kmcount = Integer.parseInt(scanner.nextLine());
- String dayornight = (scanner.nextLine());
- double TaxiprizeStart = 0.70;
- double TaxiprizeDay = 0.79;
- double TaxiprizeNight = 0.90;
- double BusPrize = 0.09;
- double TrainPrize = 0.06;
- double DayTotalWithTaxi = TaxiprizeStart + Kmcount * TaxiprizeDay;
- double NightTotalWithTaxi = TaxiprizeStart + Kmcount * TaxiprizeNight;
- double TotalWithBus = Kmcount * BusPrize;
- double TotalWithTrain = Kmcount * TrainPrize;
- if ( Kmcount < 20 && dayornight.equalsIgnoreCase("day")){
- System.out.printf("%.2f", DayTotalWithTaxi);
- }
- else if ( Kmcount < 20 && dayornight.equalsIgnoreCase("night")){
- System.out.printf("%.2f", NightTotalWithTaxi);
- } else if (Kmcount >= 20 && Kmcount < 100 ){
- System.out.printf("%.2f", TotalWithBus);
- } else if (Kmcount > 100){
- System.out.printf("%.2f", TotalWithTrain);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement