Skip to content

Instantly share code, notes, and snippets.

@nasko90
Created October 15, 2016 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nasko90/e58e8678a5cb0834131e801a47b7ef84 to your computer and use it in GitHub Desktop.
Save nasko90/e58e8678a5cb0834131e801a47b7ef84 to your computer and use it in GitHub Desktop.
using System;
using System.Globalization;
namespace HelloWorld
{
class vendingMaschine
{
static void Main()
{
double N1 = double.Parse(Console.ReadLine())*0.05;
double N2 = double.Parse(Console.ReadLine()) * 0.10;
double N3 = double.Parse(Console.ReadLine()) * 0.20;
double N4 = double.Parse(Console.ReadLine()) * 0.50;
double N5 = double.Parse(Console.ReadLine()) * 1;
double A = double.Parse(Console.ReadLine());
Math.Round(A, 2);
double P = double.Parse(Console.ReadLine());
Math.Round(P, 2);
double sum = N1 + N2 + N3 + N4 + N5;
double change = A-P;
if ((A>0.05)&&(A<1000)&&(P>0.05)&&(P<1000))
{
if ((sum >= change)&&(change>0))
{
Console.WriteLine("Yes " +(sum - change ).ToString("#.00", CultureInfo.InvariantCulture));
}
if (change<0)
{
Console.WriteLine("More " + (change*-1).ToString("#.00", CultureInfo.InvariantCulture));
}
if ((sum < change) && (change > 0))
{
Console.WriteLine("No " + (change-sum).ToString("#.00", CultureInfo.InvariantCulture));
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment