Advertisement
demirman

Untitled

Mar 31st, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.40 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         string typeFlower = Console.ReadLine();
  8.         int numFlowers = int.Parse(Console.ReadLine());
  9.         int buget = int.Parse(Console.ReadLine());
  10.        
  11.         double oneRose = 5;
  12.         double oneDahlia = 3.80;
  13.         double oneTulip = 2.80;
  14.         double oneNarcissus = 3;
  15.         double oneGladiolus = 2.50;
  16.        
  17.         switch (typeFlower)
  18.         {
  19.             case "Roses":
  20.                 double totalRoses = numFlowers * oneRose;
  21.                 if (buget >= totalRoses)
  22.                 {
  23.                     if(numFlowers > 80)
  24.                     {
  25.                         double discount = totalRoses * 0.10;
  26.                         double totalDiscount = totalRoses - discount;
  27.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  28.                         Console.Write($"{typeFlower} and {buget - totalDiscount:f2} leva left.");
  29.                     }
  30.                     else
  31.                     {
  32.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  33.                         Console.Write($"{typeFlower} and {buget - totalRoses:f2} leva left.");
  34.                     }
  35.                 }
  36.                 else
  37.                 {
  38.                     Console.WriteLine($"Not enough money, you need {totalRoses - buget:f2} leva more.");
  39.                 }
  40.                 break;
  41.                
  42.             case "Dahlias":
  43.                 double totalDahlias = numFlowers * oneDahlia;
  44.                 if (buget >= totalDahlias)
  45.                 {
  46.                     if(numFlowers > 90)
  47.                     {
  48.                         double discount = totalDahlias * 0.15;
  49.                         double totalDiscount = totalDahlias - discount;
  50.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  51.                         Console.Write($"{typeFlower} and {buget - totalDiscount:f2} leva left.");
  52.                     }
  53.                     else
  54.                     {
  55.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  56.                         Console.Write($"{typeFlower} and {buget - totalDahlias:f2} leva left.");
  57. ;                   }
  58.                 }
  59.                 else
  60.                 {
  61.                     Console.WriteLine($"Not enough money, you need {totalDahlias - buget:f2} leva more.");
  62.                 }
  63.                 break;
  64.                
  65.             case "Tulips":
  66.                 double totalTulips = numFlowers * oneTulip;
  67.                 if (buget >= totalTulips)
  68.                 {
  69.                     if(numFlowers > 80)
  70.                     {
  71.                         double discount = totalTulips * 0.15;
  72.                         double totalDiscount = totalTulips - discount;
  73.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  74.                         Console.Write($"{typeFlower} and {buget - totalDiscount:f2} leva left.");
  75.                     }
  76.                     else
  77.                     {
  78.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  79.                         Console.Write($"{typeFlower} and {buget - totalTulips:f2} leva left.");
  80.                     }
  81.                 }
  82.                 else
  83.                 {
  84.                     Console.WriteLine($"Not enough money, you need {totalTulips - buget:f2} leva more.");
  85.                 }
  86.                 break;
  87.                
  88.             case "Narcissus":
  89.                 double totalNarcissus = numFlowers * oneNarcissus;
  90.                
  91.                     if(numFlowers < 120)
  92.                     {
  93.                         double risePrice = totalNarcissus * 0.15;
  94.                         double totalUprise = totalNarcissus + risePrice;
  95.                         if (totalUprise > buget)
  96.                         {
  97.                             Console.WriteLine($"Not enough money, you need {totalUprise - buget:f2} leva more.");
  98.                         }
  99.                         else
  100.                         {
  101.                             Console.Write($"Hey, you have a great garden with {numFlowers} ");
  102.                             Console.Write($"{typeFlower} and {buget - totalUprise:f2} leva left.");
  103.                    
  104.                         }
  105.                     }
  106.                     else
  107.                     {
  108.                         if (buget >= totalNarcissus)
  109.                         {
  110.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  111.                         Console.Write($"{typeFlower} and {buget - totalNarcissus:f2} leva left.");
  112.                    
  113.                         }
  114.                         else
  115.                         {
  116.                             Console.WriteLine($"Not enough money, you need {totalNarcissus - buget:f2} leva more.");
  117.                         }
  118.                     }              
  119.                 break;
  120.                
  121.             case "Gladiolus":
  122.                 double totalGladiolus = numFlowers * oneGladiolus;
  123.                     if(numFlowers < 80)
  124.                     {
  125.                         double risePrice = totalGladiolus * 0.20;
  126.                         double totalUprise = totalGladiolus + risePrice;
  127.                         if (totalUprise > buget)
  128.                         {
  129.                             Console.WriteLine($"Not enough money, you need {totalUprise - buget:f2} leva more.");
  130.                         }
  131.                         else
  132.                         {
  133.                             Console.Write($"Hey, you have a great garden with {numFlowers} ");
  134.                             Console.Write($"{typeFlower} and {buget - totalUprise:f2} leva left.");
  135.                    
  136.                         }
  137.                     }
  138.                     else
  139.                     {
  140.                         if (buget >= totalGladiolus)
  141.                         {
  142.                         Console.Write($"Hey, you have a great garden with {numFlowers} ");
  143.                         Console.Write($"{typeFlower} and {buget - totalGladiolus:f2} leva left.");
  144.                    
  145.                         }
  146.                         else
  147.                         {
  148.                             Console.WriteLine($"Not enough money, you need {totalGladiolus - buget:f2} leva more.");
  149.                         }
  150.                     }
  151.                
  152.                 break;
  153.         }
  154.     }
  155. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement