Advertisement
MladenKarachanov

New House

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