Advertisement
Kancho

Flowers

Jan 30th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. // Garden
  2.  
  3. double expenses = 0;
  4. Scanner keyboard = new Scanner(System.in);
  5. System.out.print("Enter budged: ");
  6. int budged = keyboard.nextInt();
  7. System.out.print("Enter type of flowers: ");
  8. String typeOfFlowers = keyboard.next();
  9. System.out.print("Count of flowers: ");
  10. int count = keyboard.nextInt();
  11. System.out.print("Enter price of flowers: ");
  12. double price = keyboard.nextDouble();
  13. switch (typeOfFlowers) {
  14. case "roses":
  15. if (count > 80) {
  16. expenses = (count * price) * 0.9;
  17. }else {
  18. expenses = count * price;
  19. }
  20. break;
  21.  
  22. case "dahlias":
  23. if ( count > 90) {
  24. expenses = (count * price) * 0.85;
  25. } else {
  26. expenses = count * price;
  27. }
  28. break;
  29.  
  30. case "tulips":
  31. if (count > 90){
  32. expenses = (count * price) * 0.85;
  33. }else {
  34. expenses = price * count;
  35. }
  36. break;
  37.  
  38. case "narcissus":
  39. if (count < 120) {
  40. expenses = (price * count) * 1.15;
  41. }else {
  42. expenses = (price * count);
  43. }
  44. break;
  45.  
  46. case "gladiolus":
  47. if (count < 80){
  48. expenses = (price * count) * 1.20;
  49. }else {
  50. expenses = (price * count);
  51. }
  52. break;
  53.  
  54. default: {
  55. System.out.println("We don't offer this kind of flowers.");
  56. }
  57. }
  58. if (budged >= expenses) {
  59. System.out.printf("Yes, you have a great garden with %d %s and %.2f left lv." ,count, typeOfFlowers, (budged - expenses));
  60. } else{
  61. System.out.printf("Not enough money. Yoy are short of %.2f lv.", expenses - budged );
  62. }
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement