galinyotsev123

ProgBasicsExam1and2December2018-E03energyBooster

Dec 29th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03energyBooster{
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String fruit = scanner.nextLine();
  8. String size = scanner.nextLine();
  9. double sets = Double.parseDouble(scanner.nextLine());
  10.  
  11. double small = 2;
  12. double big = 5;
  13.  
  14. double waterMelonSmall = 56;
  15. double waterMelonBig = 28.70;
  16.  
  17. double mangoSmall = 36.66;
  18. double mangoBig = 19.60;
  19.  
  20. double pineappleSmall = 42.10;
  21. double pineappleBig = 24.80;
  22.  
  23. double raspberrySmall = 20;
  24. double raspberryBig = 15.20;
  25.  
  26. double sum = 0;
  27.  
  28. if (fruit.equalsIgnoreCase("Watermelon")) {
  29. if (size.equalsIgnoreCase("big")) {
  30. sum = waterMelonBig * big * sets;
  31. }
  32. if (size.equalsIgnoreCase("small")) {
  33. sum = waterMelonSmall * small * sets;
  34. }
  35. }
  36. else if (fruit.equalsIgnoreCase("Mango")) {
  37. if (size.equalsIgnoreCase("big")) {
  38. sum = mangoBig * big * sets;
  39. }
  40. if (size.equalsIgnoreCase("small")) {
  41. sum = mangoSmall * small * sets;
  42. }
  43. }
  44. else if (fruit.equalsIgnoreCase("Pineapple")) {
  45. if (size.equalsIgnoreCase("big")) {
  46. sum = pineappleBig * big * sets;
  47. }
  48. if (size.equalsIgnoreCase("small")) {
  49. sum = pineappleSmall * small * sets;
  50. }
  51. }
  52. else if (fruit.equalsIgnoreCase("Raspberry")) {
  53. if (size.equalsIgnoreCase("big")) {
  54. sum = raspberryBig * big * sets;
  55. }
  56. if (size.equalsIgnoreCase("small")) {
  57. sum = raspberrySmall * small * sets;
  58. }
  59. }
  60.  
  61. if (400 <= sum && sum <= 1000){
  62. sum = sum - (sum*0.15);
  63. }
  64. else if (sum > 1000){
  65. sum = sum - (sum*0.50);
  66. }
  67.  
  68. System.out.printf("%.2f lv.", sum);
  69.  
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment