Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgrammingBasics2;
- import java.util.Scanner;
- public class FuelTankPart2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String fuel = scanner.nextLine();
- double quantity = Double.parseDouble(scanner.nextLine());
- String clubCards = scanner.nextLine();
- double gasoline = 0;
- double diesel = 0;
- double gas = 0;
- double price = 0;
- double discount = 0;
- if (fuel.equals("Gas")) {
- gas = 0.93;
- if (clubCards.equals("Yes")) {
- gas = gas - 0.08;
- }
- } else if (fuel.equals("Gasoline")) {
- gasoline = 2.22;
- if (clubCards.equals("Yes")) {
- gasoline = gasoline - 0.18;
- }
- } else if (fuel.equals("Diesel")) {
- diesel = 2.33;
- if (clubCards.equals("Yes")) {
- diesel = diesel - 0.12;
- }
- }
- double sum = (gas + gasoline + diesel) * quantity;
- if (quantity > 20 && quantity <= 25) {
- sum = sum - (sum * 0.08);
- }else if (quantity > 25) {
- sum = sum - (sum * 0.10);
- }
- System.out.printf("%.2f lv.",sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement