Advertisement
Guest User

Untitled

a guest
May 21st, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class exam6task3 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. //• На първия ред е броят на закупените хризантеми – цяло число в интервала [0 ... 200]
  7. //• На втория ред е броят на закупените рози – цяло число в интервала [0 ... 200]
  8. //• На третия ред е броят на закупените лалета – цяло число в интервала [0 ... 200]
  9. //• На четвъртия ред е посочен сезона – [Spring, Summer, Аutumn, Winter]
  10. //• На петия ред е посочено дали денят е празник – [Y – да / N - не]
  11.  
  12. int countHrizantems = Integer.parseInt(scanner.nextLine());
  13. int countRoses = Integer.parseInt(scanner.nextLine());
  14. int countLales = Integer.parseInt(scanner.nextLine());
  15. String season = scanner.nextLine();
  16. String holliday = scanner.nextLine();
  17. int flowers = countHrizantems+countLales+countRoses;
  18. //Сезон Хризантеми Рози Лалета
  19. //Пролет / Лято 2.00 лв./бр. 4.10 лв./бр. 2.50 лв./бр.
  20. //Есен / Зима 3.75 лв./бр. 4.50 лв./бр. 4.15 лв./бр.
  21.  
  22. double priceHrizantems = 0.0;
  23. double priceRoses = 0.0;
  24. double priceLales = 0.0;
  25.  
  26.  
  27. if (season.equals("Spring") || season.equals("Summer")){
  28. priceHrizantems = 2.00;
  29. priceRoses = 4.10;
  30. priceLales = 2.50;
  31. if (holliday.equals("Y")){
  32. priceHrizantems = priceHrizantems*1.15;
  33. priceRoses = priceRoses*1.15;
  34. priceLales = priceLales*1.15;
  35.  
  36. }
  37.  
  38.  
  39.  
  40. }else if (season.equals("Autumn") || season.equals("Winter")){
  41. priceHrizantems = 3.75;
  42. priceRoses = 4.50;
  43. priceLales = 4.15;
  44. if (holliday.equals("Y")){
  45. priceHrizantems = priceHrizantems*1.15;
  46. priceRoses = priceRoses*1.15;
  47. priceLales = priceLales*1.15;
  48.  
  49. }
  50. }
  51. double price = countHrizantems*priceHrizantems+countRoses*priceRoses+countLales*priceLales;
  52.  
  53. if (countLales>7 && season.equals("Spring")){
  54. price = price*0.95;
  55. }if ((countRoses >= 10) && season.equals("Winter")) {
  56. price = price*0.9;
  57. }
  58. if (flowers >20) {
  59. price = price*0.8;
  60. }
  61. double result = price + 2;
  62.  
  63. System.out.printf("%.2f", result );
  64.  
  65.  
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement