Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Objects;
- import java.util.Scanner;
- public class TransportPrice {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int km = Integer.parseInt(scanner.nextLine());
- String time = scanner.nextLine();
- double price;
- if (km < 20) {
- if (Objects.equals(time, "day")) {
- price = km * 0.79 + 0.7;
- } else {
- price = km * 0.9 + 0.7;
- }
- } else if (km >= 100) {
- price = km * 0.06;
- } else {
- price = km * 0.09;
- }
- System.out.printf("%.2f\n", price);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement