aneliabogeva

New house

Nov 10th, 2020
43
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class NewHome {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. String typeFlowers = scanner.nextLine();
  7. Integer numberFlowers = Integer.parseInt(scanner.nextLine());
  8. Integer budget = Integer.parseInt(scanner.nextLine());
  9. Double totalPrice = 0.00;
  10.  
  11. if (typeFlowers.equals("Roses")) {
  12. if (numberFlowers > 80) {
  13. totalPrice = (numberFlowers * 5.00)-((numberFlowers * 5.00)*0.10);
  14. } else {
  15. totalPrice = numberFlowers * 5.00;
  16. }
  17. } else if (typeFlowers.equals("Dahlias")) {
  18. if (numberFlowers > 90) {
  19. totalPrice = (numberFlowers*3.80)-((numberFlowers*3.80)*0.15);
  20. } else {
  21. totalPrice = numberFlowers * 3.80;
  22. }
  23. }else if (typeFlowers.equals("Tulips")) {
  24. if (numberFlowers > 80) {
  25. totalPrice = (numberFlowers * 2.80)-((numberFlowers * 2.80)*0.15);
  26. } else {
  27. totalPrice = numberFlowers * 2.80;
  28. }
  29. }else if (typeFlowers.equals("Narcissus")) {
  30. if (numberFlowers < 120) {
  31. totalPrice = (numberFlowers * 3.00)+((numberFlowers * 3.00)*0.15);
  32. } else {
  33. totalPrice = numberFlowers * 3.00;
  34. }
  35. }else if (typeFlowers.equals("Gladiolus")) {
  36. if (numberFlowers < 80) {
  37. totalPrice = (numberFlowers * 2.50)+((numberFlowers * 2.50)*0.20);
  38. } else {
  39. totalPrice = numberFlowers * 2.50;
  40. }
  41. }
  42.  
  43. double finalAmount = Math.abs(totalPrice - budget);
  44. if (totalPrice <= budget) {
  45. System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", numberFlowers, typeFlowers, finalAmount);
  46. } else {
  47. System.out.printf("Not enough money, you need %.2f leva more.", finalAmount);
  48. }
  49. }
  50. }
  51.  
  52.  
RAW Paste Data