knikolov98

Untitled

Sep 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.10 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.New_House
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             string flower = Console.ReadLine();
  10.             int numberOfFlowers = int.Parse(Console.ReadLine());
  11.             double budget = double.Parse(Console.ReadLine());
  12.  
  13.             double priceFlower = 0;
  14.  
  15.             switch (flower)
  16.             {
  17.                 case "Roses":
  18.                     priceFlower = 5;
  19.                     break;
  20.                 case "Dahlias":
  21.                     priceFlower = 3.80;
  22.                     break;
  23.                 case "Tulips":
  24.                     priceFlower = 2.80;
  25.                     break;
  26.                 case "Narcissus":
  27.                     priceFlower = 3;
  28.                     break;
  29.                 case "Gladiolus":
  30.                     priceFlower = 2.50;
  31.                     break;
  32.             }
  33.  
  34.             double totalPrice = numberOfFlowers * priceFlower;
  35.  
  36.             if (numberOfFlowers > 80 && flower == "Roses")
  37.             {
  38.                 totalPrice = totalPrice - (totalPrice * 0.10);
  39.             }
  40.             else if(numberOfFlowers > 90 && flower == "Dahlias")
  41.             {
  42.                 totalPrice = totalPrice - (totalPrice * 0.15);
  43.             }
  44.             else if(numberOfFlowers > 80 && flower == "Tulips")
  45.             {
  46.                 totalPrice = totalPrice - (totalPrice * 0.15);
  47.             }
  48.             else if(numberOfFlowers < 120 && flower == "Narcissus")
  49.             {
  50.                 totalPrice = totalPrice + (totalPrice * 0.15);
  51.             }
  52.             else if(numberOfFlowers < 80 && flower == "Gladiolus")
  53.             {
  54.                 totalPrice = totalPrice + (totalPrice * 0.20);
  55.             }
  56.  
  57.             if (totalPrice > budget)
  58.             {
  59.                 Console.WriteLine($"Not enough money, you need {totalPrice - budget:f2} leva more.");
  60.             }
  61.             else
  62.             {
  63.                 Console.WriteLine($"Hey, you have a great garden with {numberOfFlowers} {flower} and {budget - totalPrice:f2} leva left.");
  64.             }
  65.         }
  66.     }
  67. }
Add Comment
Please, Sign In to add comment