Advertisement
SIRAKOV4444

Untitled

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