Advertisement
GeorgiPopov

TravelPrice

Jan 19th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * Created by georgi on 19.1.2017 г..
  5. */
  6. public class TransportPrice {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. double n = Double.parseDouble(scanner.nextLine());
  10. String dayTime = scanner.nextLine();
  11. double taxi = 0;
  12. double bus = 0;
  13. double train = 0;
  14.  
  15. if (n < 20) {
  16. double startPrice = 0.7;
  17. double dayPrice = 0.79;
  18. double nightPrice = 0.9;
  19. if (dayTime.equals("day")){
  20. taxi = startPrice + (dayPrice * n);
  21. System.out.println(taxi);
  22. } else if (dayTime.equals("night")){
  23. taxi = startPrice + (nightPrice * n);
  24. System.out.println(taxi);
  25. }
  26. } else if (n > 20 && n < 100) {
  27. double priceBus = 0.09;
  28. bus = priceBus * n;
  29. System.out.println(bus);
  30. } else if (n > 100) {
  31. double priceTrain = 0.06;
  32. bus = priceTrain * n;
  33. System.out.println(bus);
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement