aneliabogeva

Fruit shop

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