Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Coffee Machine

By: NPKumanov on Aug 21st, 2013  |  syntax: C#  |  size: 1.48 KB  |  views: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using System;
  2. using System.Threading;
  3. using System.Globalization;
  4.  
  5. //The task is not optimized
  6. //Missing: Description and code optimisation
  7.  
  8. class CoffeeMachine
  9. {
  10.     static void Main()
  11.     {
  12.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  13.         int N1 = int.Parse(Console.ReadLine());
  14.         int N2 = int.Parse(Console.ReadLine());
  15.         int N3 = int.Parse(Console.ReadLine());
  16.         int N4 = int.Parse(Console.ReadLine());
  17.         int N5 = int.Parse(Console.ReadLine());
  18.         double inputMoney = double.Parse(Console.ReadLine());
  19.         double price = double.Parse(Console.ReadLine());
  20.         double change = (double)(N1 * 0.05) + (N2 * 0.10) + (N3 * 0.20) + (N4 * 0.50) + (N5 * 1.00);
  21.         double totalMoney = (double)(N1 * 0.05) + (N2 * 0.10) + (N3 * 0.20) + (N4 * 0.50) + (N5 * 1.00) + inputMoney;
  22.         bool moneyCheck = totalMoney - inputMoney >= 0;
  23.         double moneyLeft = (inputMoney - price - change)*(-1);
  24.         double moreMoney = price - inputMoney;
  25.         double insuffMoney = inputMoney- price - change;
  26.         if (inputMoney >= price && moneyCheck && insuffMoney < 0)
  27.         {
  28.             Console.WriteLine("Yes {0:0.00}", moneyLeft);
  29.         }
  30.         else if (inputMoney < price)
  31.         {
  32.             Console.WriteLine("More {0:0.00}", moreMoney);
  33.         }
  34.         else if (inputMoney >= price && insuffMoney > 0)
  35.         {
  36.             Console.WriteLine("No {0:0.00}", insuffMoney);
  37.         }
  38.     }
  39. }