Advertisement
Soulfood

Untitled

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