Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class __FruitShop {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String fruit = scanner.nextLine();
  7. String dayFromWeek = scanner.nextLine();
  8. double quantity = Double.parseDouble(scanner.nextLine());
  9. double productPrice = 0;
  10. double totalSum = 0;
  11. if (dayFromWeek.equals("Monday") || dayFromWeek.equals("Tuesday") ||
  12. dayFromWeek.equals("Wednesday") || dayFromWeek.equals("Thursday") ||
  13. dayFromWeek.equals("Friday")) {
  14. switch (fruit) {
  15. case "banana":
  16. productPrice = 2.5;
  17. break;
  18. case "apple":
  19. productPrice = 1.2;
  20. break;
  21. case "orange":
  22. productPrice = 0.85;
  23. break;
  24. case "grapefruit":
  25. productPrice = 1.45;
  26. break;
  27. case "kiwi":
  28. productPrice = 2.7;
  29. break;
  30. case "pineapple":
  31. productPrice = 5.5;
  32. break;
  33. case "grapes":
  34. productPrice = 3.85;
  35. break;
  36.  
  37. }
  38. totalSum = productPrice * quantity;
  39. System.out.printf("%.2f", totalSum);
  40. }
  41. if (dayFromWeek.equals("Saturday") || dayFromWeek.equals("Sunday")) {
  42. switch (fruit) {
  43. case "banana":
  44. productPrice = 2.7;
  45. break;
  46. case "apple":
  47. productPrice = 1.25;
  48. break;
  49. case "orange":
  50. productPrice = 0.9;
  51. break;
  52. case "grapefruit":
  53. productPrice = 1.6;
  54. break;
  55. case "kiwi":
  56. productPrice = 3;
  57. break;
  58. case "pineapple":
  59. productPrice = 5.6;
  60. break;
  61. case "grapes":
  62. productPrice = 4.2;
  63. break;
  64. }
  65. totalSum = productPrice * quantity;
  66. System.out.printf("%.2f", totalSum);
  67. } else {
  68. System.out.println("error");
  69. }
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement