EliPerfanova

Untitled

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