Ivakis

Transport price

Sep 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class demo {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int distance = Integer.parseInt(scanner.nextLine());
  8. String time = scanner.nextLine();
  9.  
  10. double price = 0;
  11.  
  12. if(distance < 20){
  13. if(time.equals("day")){
  14. price = 0.79;
  15. }else{
  16. price = 0.90;
  17. }
  18. }else if(distance < 100){
  19. price = 0.09;
  20. }else{
  21. price = 0.06;
  22. }
  23.  
  24. double total = price * distance;
  25.  
  26. if(distance < 20){
  27. total += 0.70;
  28. }
  29. System.out.printf("%.2f", total);
  30. }
  31. }
Add Comment
Please, Sign In to add comment