Advertisement
Guest User

Untitled

a guest
Oct 18th, 2021
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Softuni
  8. {
  9.     internal class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string flower = Console.ReadLine();
  14.             int flowersCount = int.Parse(Console.ReadLine());
  15.             double budget = double.Parse(Console.ReadLine());
  16.             double flowerPrice = 0.0;
  17.  
  18.                 switch (flower)
  19.                 {
  20.                     case "Roses":
  21.                         flowerPrice = 5;
  22.                         if(flowersCount > 80)
  23.                         {
  24.                             flowerPrice = flowerPrice - (flowerPrice * 0.1);
  25.                         }
  26.                         break;
  27.                     case "Dahlias":
  28.                         flowerPrice = 3.8;
  29.                         if (flowersCount > 90)
  30.                         {
  31.                             flowerPrice = flowerPrice - (flowerPrice * 0.15);
  32.                         }
  33.                         break;
  34.                     case "Tulips":
  35.                         flowerPrice = 2.8;
  36.                         if (flowersCount > 80)
  37.                         {
  38.                             flowerPrice = flowerPrice - (flowerPrice * 0.15);
  39.                         }
  40.                         break;
  41.                     case "Narcissus":
  42.                         flowerPrice = 3;
  43.                         if (flowersCount < 120)
  44.                         {
  45.                             flowerPrice = flowerPrice + (flowerPrice * 0.15);
  46.                         }
  47.                         break;
  48.                     case "Gladiolus":
  49.                         flowerPrice = 2.5;
  50.                         if (flowersCount < 80)
  51.                         {
  52.                             flowerPrice = flowerPrice + (flowerPrice * 0.2);
  53.                         }
  54.                         break;
  55.                 }
  56.  
  57.                 double sum = flowerPrice * flowersCount;
  58.  
  59.                 if (sum <= budget)
  60.                 {
  61.                     double moneyLeft = budget - sum;
  62.                     Console.WriteLine($"Hey, you have a great garden with {flowersCount} {flower} and {moneyLeft:f2} leva left.");
  63.                 }
  64.                 else if(sum > budget)
  65.                 {
  66.                     double moneyNeeded = sum - budget;
  67.                     Console.WriteLine($"Not enough money, you need {moneyNeeded:f2} leva more.");
  68.                 }
  69.  
  70.            
  71.          
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement