DonJabone

CoffeeMachine

Nov 30th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7.  
  8.  
  9. class CoffeeMachine
  10. {
  11.      
  12.     static void Main(string[] args)
  13.     {
  14.         Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
  15.         int coinsWithAmoutOfFive = int.Parse(Console.ReadLine());
  16.         int coinsWithAmoutOfTen = int.Parse(Console.ReadLine());
  17.         int coinsWithAmoutOfTwelve = int.Parse(Console.ReadLine());
  18.         int coinsWithAmoutOfFifty = int.Parse(Console.ReadLine());
  19.         int coinsWithAmoutOfOne = int.Parse(Console.ReadLine());
  20.         decimal amoutOfInputMoney = decimal.Parse(Console.ReadLine());
  21.         decimal priceOfProduct = decimal.Parse(Console.ReadLine());
  22.         decimal totalMoneyInMachine = (decimal)((coinsWithAmoutOfFive * 0.05) + (coinsWithAmoutOfTen * 0.10) + (coinsWithAmoutOfTwelve * 0.20) + (coinsWithAmoutOfFifty * 0.50) + coinsWithAmoutOfOne);
  23.         if (amoutOfInputMoney - priceOfProduct < 0)
  24.         {
  25.             Console.WriteLine("More {0}", Math.Abs(Math.Round(amoutOfInputMoney - priceOfProduct, 2)));
  26.         }
  27.         else
  28.         {
  29.             if ((totalMoneyInMachine + priceOfProduct) >= amoutOfInputMoney)
  30.             {
  31.                 Console.WriteLine("Yes {0}", Math.Round((totalMoneyInMachine + priceOfProduct) - amoutOfInputMoney, 2));
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine("No {0}", Math.Abs(Math.Round((totalMoneyInMachine + priceOfProduct) - amoutOfInputMoney, 2)));
  36.             }
  37.         }
  38.          
  39.  
  40.  
  41.          
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment