Advertisement
Guest User

Untitled

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