Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package trans;
- import java.util.Scanner;
- public class transport {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.print("Raztoqnie = ");
- int distance = Integer.parseInt(scan.nextLine());
- System.out.print("Vreme = ");
- String time = scan.nextLine();
- double taxi = 0.00;
- double bus = 0.09;
- double train = 0.06;
- if(time.equals("day")) {
- taxi = 0.79;
- } else if (time.equals("night")){
- taxi = 0.90;
- }
- if(distance < 150) {
- System.out.println("Taxi = " + distance * taxi);
- }
- if (distance < 20) {
- System.out.println("Bus = " + distance * bus);
- }
- if (distance < 100 ) {
- System.out.println("Vlak = " + distance * train);
- }
- if(taxi < bus || taxi < train) {
- System.out.println("The cheapest is the taxi");
- } else if(bus < taxi || bus < train) {
- System.out.println("The cheapest is the bus");
- } else if(train < taxi || train < bus) {
- System.out.println("The cheapest is the train");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment