Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.lang.String;
- public class CheapestTransport {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int kM = Integer.parseInt(console.nextLine());
- String time = console.nextLine();
- double taxiDay = 0.79;
- double taxiNight = 0.90;
- double serviceFee = 0.70;
- double bus = 0.09;
- double train = 0.06;
- double cheapestTransport = 0;
- if(kM <= 20){
- if(time.equals("day")){
- cheapestTransport = kM * taxiDay + serviceFee;
- System.out.printf("taxi: %.2f", cheapestTransport);
- }else{
- cheapestTransport = kM * taxiNight +serviceFee;
- System.out.printf("taxi: %.2f", cheapestTransport);
- }
- }else if(kM > 20 && kM <= 100){
- cheapestTransport = kM * bus;
- System.out.printf("bus: %.2f", cheapestTransport);
- }else if(kM > 100){
- cheapestTransport = kM * train;
- System.out.printf("train: %.2f", cheapestTransport);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment