Advertisement
MladenKarachanov

FruitShop

Dec 7th, 2022
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. package ConditionalStatementsAdvancedLab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FruitShop1 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. String fruit = scanner.nextLine();
  9. String day = scanner.nextLine();
  10. double num = Double.parseDouble(scanner.nextLine());
  11. double price = 0;
  12. if (day.equals("Monday") || day.equals("Tuesday")
  13. || day.equals("Wednesday") || day.equals("Thursday")
  14. || day.equals("Friday")) {
  15.  
  16. if (fruit.equals("banana")) {
  17. price = 2.50;
  18.  
  19. } else if (fruit.equals("apple")) {
  20. price = 1.20;
  21.  
  22. } else if (fruit.equals("orange")) {
  23. price = 0.85;
  24.  
  25. } else if (fruit.equals("grapefruit")) {
  26. price = 1.45;
  27.  
  28. } else if (fruit.equals("kiwi")) {
  29. price = 2.70;
  30.  
  31. } else if (fruit.equals("pineapple")) {
  32. price = 5.50;
  33.  
  34. } else if (fruit.equals("grapes")) {
  35. price = 3.85;
  36.  
  37. }
  38. } else if (day.equals("Saturday") ||
  39. day.equals("Sunday")) {
  40.  
  41. if (fruit.equals("banana")) {
  42. price = 2.70;
  43.  
  44. } else if (fruit.equals("apple")) {
  45. price = 1.25;
  46. } else if (fruit.equals("orange")) {
  47. price = 0.90;
  48. } else if (fruit.equals("grapefruit")) {
  49. price = 1.60;
  50. } else if (fruit.equals("kiwi")) {
  51. price = 3.00;
  52. } else if (fruit.equals("pineapple")) {
  53. price = 5.60;
  54. } else if (fruit.equals("grapes")) {
  55. price = 4.20;
  56.  
  57. }
  58. }else {
  59. System.out.println("error");
  60.  
  61. }
  62. double result = price * num;
  63.  
  64. System.out.printf("%.2f", result);
  65.  
  66.  
  67.  
  68. }
  69.  
  70.  
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement