Проблем със задача
Здрравейте! Имам проблем със задача Vending machine-7 https://softuni.bg/trainings/resources/officedocument/37239/exercise-technology-fundamentals-with-csharp-january-2019/2237
Не мога да се сетя как да изкарам "Sorry, not enough money"
Ето моя код и благодаря предварително.
using System;
namespace Exam
{
class Program
{
static void Main(string[] args)
{
string input = Console.ReadLine();
double sum = 0;
while (input!="Start")
{
double coins = double.Parse(input);
if (coins == 0.1 || coins==0.20 || coins==0.5 || coins==1 || coins==2)
{
sum += coins;
}
else
{
Console.WriteLine($"Cannot accept {coins}");
}
input = Console.ReadLine();
}
string input2 = Console.ReadLine();
while (input2 != "End")
{
string product =(input2);
if (product=="Coke" && sum>=1)
{
Console.WriteLine("Purchased coke");
sum = sum - 1;
}
if (product=="Nuts"&&sum>=2)
{
Console.WriteLine("Purchased nuts");
sum = sum - 2;
}
if (product=="Water"&&sum>=0.7)
{
Console.WriteLine("Purchased water");
sum = sum - 0.7;
}
if (product=="Crisps"&&sum>=1.5)
{
Console.WriteLine("You purchased crisps");
sum = sum - 1.5;
}
if (product=="Soda"&&sum>=0.8)
{
Console.WriteLine("Purchased soda");
sum = sum - 0.8;
}
if (product!="Coke"&& product != "Soda"&& product != "Water"&&product!="Nuts"&&product!="Crisps")
{
Console.WriteLine("Invalid product");
}
if (sum<0.70)
{
Console.WriteLine("Sorry, not enough money");
}
input2 = Console.ReadLine();
}
Console.WriteLine($"Change: {sum :f2}");
}
}
}