Advertisement
desislava_topuzakova

03. New House

Jul 31st, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. package ExsWeek_03;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class NewHouse {
  6. public static void main(String[] args) {
  7.  
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. String flowersName = scanner.nextLine();
  11. int flowersNum = Integer.parseInt(scanner.nextLine());
  12. int budget = Integer.parseInt(scanner.nextLine());
  13.  
  14. double totalSum = 0;
  15.  
  16. switch (flowersName){
  17.  
  18. case "Roses":
  19. totalSum = flowersNum * 5;
  20. if (flowersNum > 80){
  21. totalSum = totalSum - totalSum * 0.10;
  22. }
  23. break;
  24.  
  25. case "Dahlias":
  26. totalSum = flowersNum * 3.80;
  27. if (flowersNum > 90){
  28. totalSum = totalSum -totalSum * 0.15;
  29. }
  30. break;
  31.  
  32. case "Tulips":
  33. totalSum = flowersNum * 2.80;
  34. if (flowersNum > 80){
  35. totalSum = totalSum - totalSum * 0.15;
  36. }
  37. break;
  38.  
  39. case "Narcissus":
  40. totalSum = flowersNum * 3;
  41. if (flowersNum < 120){
  42. totalSum = totalSum + totalSum * 0.15;
  43. }
  44. break;
  45.  
  46. case "Gladiolus":
  47. totalSum = flowersNum * 2.50;
  48. if (flowersNum < 80){
  49. totalSum = totalSum + totalSum * 0.20;
  50. }
  51. break;
  52.  
  53. }
  54. double diff = Math.abs(budget - totalSum);
  55. if (budget >= totalSum){
  56. System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", flowersNum, flowersName, diff);
  57. }else{
  58. System.out.printf("Not enough money, you need %.2f leva more.", diff);
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement