Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FuelTankPt2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fuelType = scanner.nextLine();
- double fuelQuantity = Double.parseDouble(scanner.nextLine());
- boolean hasClubCard = scanner.nextLine().equals("Yes");
- double price = 0.0;
- if ("Gas".equals(fuelType)) {
- price = 0.93;
- if (hasClubCard) {
- price -= 0.08;
- }
- } else if ("Gasoline".equals(fuelType)) {
- price = 2.22;
- if (hasClubCard) {
- price -= 0.18;
- }
- } else if ("Diesel".equals(fuelType)) {
- price = 2.33;
- if (hasClubCard) {
- price -= 0.12;
- }
- }
- price *= fuelQuantity;
- if (fuelQuantity >= 20 && fuelQuantity <= 25) {
- price *= 0.92;
- } else if (fuelQuantity > 25) {
- price *= 0.9;
- }
- System.out.println(String.format("%.2f lv.", price));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment