Advertisement
SUni2020

03. Energy Booster

Mar 29th, 2020
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EnergyBooster{
  4.  
  5.  
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. // Плод - текст с възможности: "Watermelon", "Mango", "Pineapple" или "Raspberry"
  10. String fruit = scanner.nextLine();
  11. //2. Размерът на сета - текст с възможности: "small" или "big"
  12. String packageSize = scanner.nextLine();
  13. //3. Брой на поръчаните сетове - цяло число в интервала [1 … 10000]
  14. int numberOfPackages = Integer.parseInt(scanner.nextLine());
  15.  
  16.  
  17. // Диня Манго Ананас Малина "Watermelon", "Mango", "Pineapple" или "Raspberry"
  18. // 2 броя (small) 56 лв./бр. 36.66 лв./бр. 42.10 лв./бр. 20 лв./бр.
  19. // 5 броя (big) 28.70 лв./бр. 19.60 лв./бр. 24.80 лв./бр. 15.20 лв./бр.
  20. double PriceWithoutDiscount = 0;
  21. switch (fruit) {
  22. case "Watermelon":
  23. switch (packageSize) {
  24. case "small":
  25. PriceWithoutDiscount = 56 * 2;
  26.  
  27. break;
  28.  
  29. case "big":
  30. PriceWithoutDiscount = 28.70 * 5;
  31. break;
  32. }
  33. break;
  34. case "Mango":
  35. switch (packageSize) {
  36. case "small":
  37. PriceWithoutDiscount = 36.66 * 2;
  38. break;
  39.  
  40. case "big":
  41. PriceWithoutDiscount = 19.60 * 5;
  42. break;
  43. }
  44. break;
  45. case "Pineapple":
  46. switch (packageSize) {
  47. case "small":
  48. PriceWithoutDiscount = 42.10 * 2;
  49. break;
  50.  
  51. case "big":
  52. PriceWithoutDiscount = 24.80 * 5;
  53. break;
  54. }
  55. break;
  56. case "Raspberry":
  57. switch (packageSize) {
  58. case "small":
  59. PriceWithoutDiscount = 20 * 2;
  60. break;
  61.  
  62. case "big":
  63. PriceWithoutDiscount = 15.20 * 5;
  64. }
  65.  
  66. }
  67. double TotalPriceWithoutDiscount = PriceWithoutDiscount * numberOfPackages;
  68. if ( 400 <= TotalPriceWithoutDiscount && TotalPriceWithoutDiscount <= 1000) {
  69.  
  70. double Discount = 0.15 * TotalPriceWithoutDiscount;
  71. double EndPrice = TotalPriceWithoutDiscount - Discount;
  72. System.out.printf("%.2f lv.", EndPrice);
  73.  
  74. }
  75. else if (TotalPriceWithoutDiscount > 1000) {
  76. double Discount = 0.5 * TotalPriceWithoutDiscount;
  77. double EndPrice = TotalPriceWithoutDiscount - Discount;
  78. System.out.printf("%.2f lv.", EndPrice);
  79. }
  80. else{
  81. System.out.printf("%.2f lv.",TotalPriceWithoutDiscount);
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement