desislava_topuzakova

Untitled

Jan 20th, 2022
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FuelTankPt2 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String fuelType = scanner.nextLine();
  8. double fuelQuantity = Double.parseDouble(scanner.nextLine());
  9. boolean hasClubCard = scanner.nextLine().equals("Yes");
  10.  
  11. double price = 0.0;
  12.  
  13. if ("Gas".equals(fuelType)) {
  14. price = 0.93;
  15. if (hasClubCard) {
  16. price -= 0.08;
  17. }
  18. } else if ("Gasoline".equals(fuelType)) {
  19. price = 2.22;
  20. if (hasClubCard) {
  21. price -= 0.18;
  22. }
  23. } else if ("Diesel".equals(fuelType)) {
  24. price = 2.33;
  25. if (hasClubCard) {
  26. price -= 0.12;
  27. }
  28. }
  29.  
  30. price *= fuelQuantity;
  31.  
  32. if (fuelQuantity >= 20 && fuelQuantity <= 25) {
  33. price *= 0.92;
  34. } else if (fuelQuantity > 25) {
  35. price *= 0.9;
  36. }
  37.  
  38. System.out.println(String.format("%.2f lv.", price));
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment