Guest User

Untitled

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