Advertisement
Guest User

Untitled

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