Boyan5

Untitled

Jun 8th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. package trans;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class transport {
  6.  
  7. public static void main(String[] args) {
  8. Scanner scan = new Scanner(System.in);
  9.  
  10.  
  11. System.out.print("Raztoqnie = ");
  12. int distance = Integer.parseInt(scan.nextLine());
  13.  
  14. System.out.print("Vreme = ");
  15. String time = scan.nextLine();
  16.  
  17. double taxi = 0.00;
  18. double bus = 0.09;
  19. double train = 0.06;
  20.  
  21. if(time.equals("day")) {
  22. taxi = 0.79;
  23. } else if (time.equals("night")){
  24. taxi = 0.90;
  25. }
  26.  
  27. if(distance < 150) {
  28. System.out.println("Taxi = " + distance * taxi);
  29. }
  30.  
  31. if (distance < 20) {
  32. System.out.println("Bus = " + distance * bus);
  33. }
  34.  
  35. if (distance < 100 ) {
  36. System.out.println("Vlak = " + distance * train);
  37. }
  38.  
  39. if(taxi < bus || taxi < train) {
  40. System.out.println("The cheapest is the taxi");
  41. } else if(bus < taxi || bus < train) {
  42. System.out.println("The cheapest is the bus");
  43. } else if(train < taxi || train < bus) {
  44. System.out.println("The cheapest is the train");
  45. }
  46. }
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment