Advertisement
IvanITD

03.NewHouse

Jan 16th, 2024
934
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | Source Code | 0 0
  1. using System.ComponentModel.Design;
  2.  
  3. string flowersType = Console.ReadLine();
  4. int flowersAmmount = int.Parse(Console.ReadLine());
  5. int budget = int.Parse(Console.ReadLine());
  6.  
  7. double roses = 5.00;
  8. double dahlias = 3.80;
  9. double tulips = 2.80;
  10. double narcissus = 3.00;
  11. double gladiolus = 2.50;
  12.  
  13. double price = 0.00;
  14.  
  15. // Here we solved the task with the if-else statement
  16. if (flowersType == "Roses")
  17. {
  18.     if (flowersAmmount > 80)
  19.     {
  20.         price = flowersAmmount * roses;
  21.          price -= (price * 0.10);
  22.     }
  23.     else
  24.     {
  25.         price = flowersAmmount * roses;
  26.     }
  27. }
  28. else if (flowersType == "Dahlias")
  29. {
  30.     if (flowersAmmount > 90)
  31.     {
  32.         price = flowersAmmount * dahlias;
  33.          price -= (price * 0.15);
  34.     }
  35.     else
  36.     {
  37.         price = flowersAmmount * dahlias;
  38.     }
  39. }
  40. else if (flowersType == "Tulips")
  41. {
  42.     if (flowersAmmount > 80)
  43.     {
  44.         price = flowersAmmount * tulips;
  45.          price -= (price * 0.15);
  46.     }
  47.     else
  48.     {
  49.         price = flowersAmmount * tulips;
  50.     }
  51. }
  52. else if (flowersType == "Narcissus")
  53. {
  54.     if (flowersAmmount < 120)
  55.     {
  56.         price = flowersAmmount * narcissus;
  57.          price += (price * 0.15);
  58.     }
  59.     else
  60.     {
  61.         price = flowersAmmount * narcissus;
  62.     }
  63. }
  64. else if (flowersType == "Gladiolus")
  65. {
  66.     if (flowersAmmount < 80)
  67.     {
  68.          price = flowersAmmount * gladiolus;
  69.          price += (price * 0.20);
  70.     }
  71.     else
  72.     {
  73.          price = flowersAmmount * gladiolus;
  74.     }
  75. }
  76.  
  77. if (budget >= price)
  78. {
  79.     Console.WriteLine($"Hey, you have a great garden with {flowersAmmount} {flowersType} and {budget - price:F2} leva left.");
  80. }
  81. else if (budget < price)
  82. {
  83.     Console.WriteLine($"Not enough money, you need {price - budget:F2} leva more.");
  84. }
  85.  
Tags: C#
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement