Advertisement
MladenKarachanov

FuelTankPart2

Jan 23rd, 2024
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. package ProgrammingBasics2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FuelTankPart2 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String fuel = scanner.nextLine();
  9.         double quantity = Double.parseDouble(scanner.nextLine());
  10.         String clubCards = scanner.nextLine();
  11.         double gasoline = 0;
  12.         double diesel = 0;
  13.         double gas = 0;
  14.         double price = 0;
  15.         double discount = 0;
  16.         if (fuel.equals("Gas")) {
  17.             gas = 0.93;
  18.             if (clubCards.equals("Yes")) {
  19.                 gas = gas - 0.08;
  20.             }
  21.  
  22.         } else if (fuel.equals("Gasoline")) {
  23.             gasoline = 2.22;
  24.             if (clubCards.equals("Yes")) {
  25.                 gasoline = gasoline - 0.18;
  26.             }
  27.  
  28.         } else if (fuel.equals("Diesel")) {
  29.             diesel = 2.33;
  30.             if (clubCards.equals("Yes")) {
  31.                 diesel = diesel - 0.12;
  32.             }
  33.  
  34.  
  35.         }
  36.         double sum = (gas + gasoline + diesel) * quantity;
  37.         if (quantity > 20 && quantity <= 25) {
  38.             sum = sum - (sum * 0.08);
  39.  
  40.  
  41.         }else  if (quantity > 25) {
  42.             sum = sum - (sum * 0.10);
  43.         }
  44.  
  45.         System.out.printf("%.2f lv.",sum);
  46.     }
  47. }
  48.  
  49.  
  50.  
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement