aneliabogeva

Fishing Boad

Nov 10th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NewHome {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. Integer budget = Integer.parseInt(scanner.nextLine());
  7. String season = scanner.nextLine();
  8. Integer numberPeople = Integer.parseInt(scanner.nextLine());
  9. Double totalPrice = 0.00;
  10.  
  11. switch (season){
  12. case "Spring":
  13. if (numberPeople <= 6){
  14. totalPrice = 3000-(3000*0.10);
  15. }else if(numberPeople >= 7 && numberPeople <=11){
  16. totalPrice = 3000-(3000*0.15);
  17. }else if(numberPeople >11){
  18. totalPrice = 3000-(3000*0.25);
  19. }else{}
  20. if(numberPeople % 2 == 0){
  21. totalPrice = totalPrice - totalPrice*0.05;
  22. }else{}
  23. break;
  24. case "Summer":
  25. if (numberPeople <= 6){
  26. totalPrice = 4200-(4200*0.10);
  27. }else if(numberPeople >= 7 && numberPeople <=11){
  28. totalPrice = 4200-(4200*0.15);
  29. }else if(numberPeople >11){
  30. totalPrice = 4200-(4200*0.25);
  31. }else{}
  32. if(numberPeople % 2 == 0){
  33. totalPrice = totalPrice - totalPrice*0.05;
  34. }else{}
  35. break;
  36. case "Autumn":
  37. if (numberPeople <= 6){
  38. totalPrice = 4200-(4200*0.10);
  39. }else if(numberPeople >= 7 && numberPeople <=11){
  40. totalPrice = 4200-(4200*0.15);
  41. }else if(numberPeople >11){
  42. totalPrice = 4200-(4200*0.25);
  43. }else{}
  44. break;
  45. case "Winter":
  46. if (numberPeople <= 6){
  47. totalPrice = 2600-(2600*0.10);
  48. }else if(numberPeople >= 7 && numberPeople <=11){
  49. totalPrice = 2600-(2600*0.15);
  50. }else if(numberPeople >11){
  51. totalPrice = 2600-(2600*0.25);
  52. }else{}
  53. if(numberPeople % 2 == 0){
  54. totalPrice = totalPrice - totalPrice*0.05;
  55. }else{}
  56. break;
  57. default:
  58. break;
  59. }
  60.  
  61.  
  62. double finalAmount = Math.abs(totalPrice - budget);
  63. if (totalPrice <= budget) {
  64. System.out.printf("Yes! You have %.2f leva left.", finalAmount);
  65. } else {
  66. System.out.printf("Not enough money! You need %.2f leva.", finalAmount);
  67. }
  68. }
  69. }
  70.  
  71.  
Add Comment
Please, Sign In to add comment