Advertisement
galinyotsev123

ProgBasicsJavaBook3.2SimpleConditions01TransportPrice

Jan 23rd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. int km = Integer.parseInt(scanner.nextLine());
  9. String dayOrnight = scanner.nextLine();
  10.  
  11. double transportPrice = 0;
  12.  
  13. if (km < 20) {
  14. if (dayOrnight.equalsIgnoreCase("day")) {
  15. transportPrice = 0.70 + (km * 0.79);
  16. } else if (dayOrnight.equalsIgnoreCase("night")) {
  17. transportPrice = 0.70 + (km * 0.90);
  18. }
  19. } else if (km >= 20 && km < 100) {
  20. transportPrice = 0.09 * km;
  21. } else if (km >= 100) {
  22. transportPrice = 0.06 * km;
  23. }
  24. System.out.println(transportPrice);
  25.  
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement