04. Vacation problem
Не мога да разбера защо в judge ми дава 88 точки
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace while4
{
class Program
{
static void Main(string[] args)
{
double neededMoney = double.Parse(Console.ReadLine());
double money = double.Parse(Console.ReadLine());
double sum = money;
int days = 0;
int counterSpend = 0;
while (true)
{
string action = Console.ReadLine();
double add = double.Parse(Console.ReadLine());
days++;
if (action == "save")
{
sum = sum + add;
counterSpend--;
if (counterSpend <= 0)
{
counterSpend = 0;
}
}
if (action == "spend")
{
sum = sum - add;
counterSpend++;
if (sum <= 0)
{
sum = 0;
}
}
if (sum >= neededMoney)
{
Console.WriteLine($"You saved the money for {days} days.");
break;
}
if (counterSpend == 5)
{
Console.WriteLine("You can't save the money.");
Console.WriteLine($"{days}");
break;
}
}
}
}
}
Да, благодаря