Advertisement
locotribal

Untitled

Jul 18th, 2019
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. package L08_Conditional_Statements_More_Exercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Upr09_Fuel_Tank_Part_2 {
  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. String clubCard = scanner.nextLine();
  12.  
  13. double price = 0;
  14. if ("Gas".equals(fuel) && "Yes".equals(clubCard)) {
  15. if (litres >= 20 && litres <= 25) {
  16. price = (litres * 0.85) * 0.92;
  17. }if (litres > 25) {
  18. price = (litres * 0.85) * 0.9;
  19. }
  20. }
  21.  
  22. if ("Gas".equals(fuel) && "No".equals(clubCard)) {
  23. price = litres * 0.93;
  24. if (litres >= 20 && litres <= 25) {
  25. price = price * 0.92;
  26. }if (litres > 25) {
  27. price = price * 0.9;
  28. }
  29. }
  30.  
  31. if ("Gasoline".equals(fuel) && "Yes".equals(clubCard)) {
  32. if (litres >= 20 && litres <= 25) {
  33. price = (litres * 2.04) * 0.92;
  34. }if (litres > 25) {
  35. price = (litres * 2.04) * 0.9;
  36. }
  37. }
  38.  
  39. if ("Gasoline".equals(fuel) && "No".equals(clubCard)) {
  40. price = litres * 2.22;
  41. if (litres >= 20 && litres <= 25) {
  42. price = price * 0.92;
  43. }else if (litres > 25) {
  44. price = price * 0.9;
  45. }
  46. }
  47.  
  48. if ("Diesel".equals(fuel) && "Yes".equals(clubCard)) {
  49. if (litres >= 20 && litres <= 25) {
  50. price = (litres * 2.21) * 0.92;
  51. }else if (litres > 25) {
  52. price = (litres * 2.21) * 0.9;
  53. }
  54. }
  55.  
  56. if ("Diesel".equals(fuel) && "No".equals(clubCard)) {
  57. price = litres * 2.33;
  58. if (litres >= 20 && litres <= 25) {
  59. price = price * 0.92;
  60. }else if (litres > 25) {
  61. price = price * 0.9;
  62. }
  63. }
  64.  
  65. System.out.printf("%.2f lv.", price);
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement