Daniel_007

04. New House

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