Advertisement
locotribal

Untitled

Jul 14th, 2019
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. package L08_Conditional_Statements_More_Exercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Upr08_Fuel_Tank {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String fuel = scanner.nextLine();
  10. double litres = Double.parseDouble(scanner.nextLine());
  11.  
  12. if (!"Diesel".equals(fuel)) {
  13. if (!"Gasoline".equals(fuel)) {
  14. if (!"Gas".equals(fuel)) {
  15. System.out.println("Invalid fuel!");
  16. }
  17. }
  18. }
  19.  
  20. if (litres >= 25) {
  21. if ("Diesel".equals(fuel) || "Gasoline".equals(fuel) || "Gas".equals(fuel)) {
  22. System.out.printf("You have enough %s.", fuel.toLowerCase());
  23. }
  24. }
  25.  
  26. if (litres < 25) {
  27. System.out.printf("Fill your tank with %s!", fuel.toLowerCase());
  28. }
  29.  
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement