Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Objects;
- import java.util.Scanner;
- public class FuelTank2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fuel = scanner.nextLine();
- double liters = Double.parseDouble(scanner.nextLine());
- String cart = scanner.nextLine();
- double literPrice = 0;
- if (Objects.equals(cart, "No")) {
- if (Objects.equals(fuel, "Gas")) {
- literPrice = 0.93;
- } else if (Objects.equals(fuel, "Gasoline")) {
- literPrice = 2.22;
- } else if (Objects.equals(fuel, "Diesel")) {
- literPrice = 2.33;
- }
- } else {
- if (Objects.equals(fuel, "Gas")) {
- literPrice = 0.85;
- } else if (Objects.equals(fuel, "Gasoline")) {
- literPrice = 2.04;
- } else if (Objects.equals(fuel, "Diesel")) {
- literPrice = 2.21;
- }
- }
- if (liters >= 20 && liters <= 25) {
- literPrice *= 0.92;
- } else if (liters > 25) {
- literPrice *= 0.9;
- }
- System.out.printf("%.2f lv.\n", literPrice * liters);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement