Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace exr_20_newHouse
- {
- class Program
- {
- static void Main(string[] args)
- {
- // data input
- string flower = Console.ReadLine().ToLower();
- int numFlowers = int.Parse(Console.ReadLine());
- decimal money = decimal.Parse(Console.ReadLine());
- // help variables
- decimal totalCost = 0M;
- string result = string.Empty;
- decimal moneyLeft = 0M;
- // determine the price dependig on the flower choice
- switch (flower)
- {
- case "roses":
- totalCost = (numFlowers > 80) ? numFlowers * 5M * 0.90M : numFlowers * 5M;
- break;
- case "dahlias":
- totalCost = (numFlowers > 90) ? numFlowers * 3.80M * 0.85M : numFlowers * 3.80M;
- break;
- case "tulips":
- totalCost = (numFlowers > 80) ? numFlowers * 2.80M * 0.85M : numFlowers * 2.80M;
- break;
- case "narcissus":
- totalCost = (numFlowers < 120) ? numFlowers * 3.00M * 1.15M : numFlowers * 3.00M;
- break;
- case "gladiolus":
- totalCost = (numFlowers < 80) ? numFlowers * 2.50M * 1.20M : numFlowers * 2.50M;
- break;
- }
- // compare budget to total cost
- moneyLeft = money - totalCost;
- if (moneyLeft > 0)
- {
- flower = flower.First().ToString().ToUpper() + flower.Substring(1);
- result = string.Format("Hey, you have a great garden with {0} {1} " +
- "and {2:F2} leva left.", numFlowers, flower, moneyLeft);
- }
- else
- {
- result = string.Format("Not enough money, you need {0:F2} leva more.",
- Math.Abs(moneyLeft));
- }
- // print the result
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement