Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TruckDriver {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String season = scanner.nextLine();
- double km = Double.parseDouble(scanner.nextLine());
- double kmPrice = 0;
- if (km > 0 && km <= 5000) {
- kmPrice = switch (season) {
- case "Spring", "Autumn" -> 0.75;
- case "Summer" -> 0.90;
- case "Winter" -> 1.05;
- default -> kmPrice;
- };
- } else if (km > 5000 && km <= 10000) {
- kmPrice = switch (season) {
- case "Spring", "Autumn" -> 0.95;
- case "Summer" -> 1.10;
- case "Winter" -> 1.25;
- default -> kmPrice;
- };
- } else if (km > 10000 && km <= 20000) {
- kmPrice = 1.45;
- }
- System.out.printf("%.2f\n", kmPrice * km * 4 * 0.90);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement