Guest User

Untitled

a guest
Jul 3rd, 2019
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class NewHouse {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. String flowers = scanner.nextLine();
  9. int number = Integer.parseInt(scanner.nextLine());
  10. double budget = Double.parseDouble(scanner.nextLine());
  11. double cost = 0;
  12.  
  13. if (flowers.equalsIgnoreCase("Roses")) {
  14. if (number >= 80) {
  15. cost = number * 5;
  16. cost = cost - cost * 0.1;
  17. } else {
  18. cost = number * 5;
  19. }
  20. } else if (flowers.equalsIgnoreCase("Dahlias")) {
  21. if (number >= 90) {
  22. cost = number * 3.80;
  23. cost = cost - cost * 0.15;
  24. } else {
  25. cost = number * 3.80;
  26. }
  27. } else if (flowers.equalsIgnoreCase("Tulips")) {
  28. if (number >= 80) {
  29. cost =number * 2.80;
  30. cost = cost - cost * 0.15;
  31. } else {
  32. cost = number * 2.80;
  33. }
  34. } else if (flowers.equalsIgnoreCase("Narcissus")) {
  35. if (number < 120) {
  36. cost = number * 3;
  37. cost = cost + cost * 0.15;
  38. } else {
  39. cost = number * 3;
  40. }
  41. } else if (flowers.equalsIgnoreCase("Gladiolus")) {
  42. if (number < 80) {
  43. cost = number * 2.50;
  44. cost = cost + cost * 0.20;
  45. } else {
  46. cost = number * 2.50;
  47. }
  48. }
  49.  
  50. if (budget > cost) {
  51. double difference = budget - cost;
  52. System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", number, flowers, difference);
  53. } else if (cost >budget) {
  54. double needed = cost - budget;
  55. System.out.printf("Not enough money, you need %.2f leva more.", needed);
  56. }
  57.  
  58. }
  59.  
  60. }
RAW Paste Data