Advertisement
Yancho_code

04. Wedding Decoration

Apr 18th, 2019
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _04.Wedding_Decoration
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double budget = double.Parse(Console.ReadLine());
  14.             double spendMoney = 0;
  15.  
  16.             int Bcount = 0;
  17.             int Fcount = 0;
  18.             int Ccount = 0;
  19.             int Rcount = 0;
  20.  
  21.  
  22.             while (true)
  23.             {  
  24.              string stokTipe = Console.ReadLine();
  25.  
  26.                 if (stokTipe=="stop")
  27.                 {
  28.                     break;
  29.                 }
  30.  
  31.              int count = int.Parse(Console.ReadLine());
  32.                
  33.                 switch (stokTipe)
  34.                 {
  35.                     case "balloons":
  36.                         spendMoney = spendMoney + (count * 0.1);
  37.                         Bcount += count;
  38.                         break;
  39.  
  40.                     case "flowers":
  41.                         spendMoney = spendMoney + (count * 1.5);
  42.                         Fcount += count;
  43.                         break;
  44.  
  45.                     case "candles":
  46.                         spendMoney = spendMoney + (count * 0.5);
  47.                         Ccount += count;
  48.                         break;
  49.  
  50.                     case "ribbon":
  51.                         spendMoney = spendMoney + (count * 2.0);
  52.                         Rcount += count;
  53.                         break;
  54.                 }
  55.  
  56.             }
  57.             if (budget > spendMoney)
  58.             {
  59.                 Console.WriteLine($"Spend money: {spendMoney:f2}");
  60.                 Console.WriteLine($"Money left: {budget - spendMoney:f2}");
  61.                 Console.WriteLine($"Purchased decoration is {Bcount} balloons, {Rcount} m ribbon, {Fcount} flowers and {Ccount} candles.");
  62.             }
  63.             else
  64.             {
  65.                 Console.WriteLine("All money is spent!");
  66.                 Console.WriteLine($"Purchased decoration is {Bcount} balloons, {Rcount} m ribbon, {Fcount} flowers and {Ccount} candles.");
  67.             }
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement