nikolayneykov

Untitled

Nov 4th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2.  
  3. class WeddingDecoration
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         double budget = double.Parse(Console.ReadLine());
  8.         double ribbon = 0;
  9.         double balloons = 0;
  10.         double flowers = 0;
  11.         double candles = 0;
  12.         string stock = string.Empty;
  13.         double spendMoney = 0;
  14.         while (budget > spendMoney && (stock = Console.ReadLine()) != "stop")
  15.         {
  16.             double quantity = double.Parse(Console.ReadLine());
  17.             double currentPrice = 0;
  18.             switch (stock)
  19.             {
  20.                 case "flowers": currentPrice = quantity * 1.5; flowers += quantity; break;
  21.                 case "balloons": currentPrice = quantity * 0.1; balloons += quantity; break;
  22.                 case "ribbon": currentPrice = quantity * 2; ribbon += quantity; break;
  23.                 case "candles": currentPrice = quantity * 0.5; candles += quantity; break;
  24.             }
  25.             spendMoney += currentPrice;
  26.         }
  27.         Console.WriteLine(budget <= spendMoney ?
  28.             "All money is spent!" :
  29.             $"Spend money: {spendMoney:F2}\nMoney left: {budget - spendMoney:F2}");
  30.         Console.WriteLine("Purchased decoration is " +
  31.             $"{balloons} balloons, {ribbon} m ribbon, {flowers} flowers and {candles} candles.");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment