Programming basics C# While-Loop Упражнение 4 Vacation.
Джъдж ми дава 77/100 и феилва тест 7 и 9. Иначе висчко работи във VS. Къде бъркам?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Vacation
{
class Program
{
static void Main(string[] args)
{
double moneyForVacation = double.Parse(Console.ReadLine());
double moneyAvailable = double.Parse(Console.ReadLine());
string action = "";
double sum = 0;
int spendCounter = 0;
int counter = 0;
while (true)
{
action = Console.ReadLine();
if (action == "spend")
{
sum = double.Parse(Console.ReadLine());
counter++;
spendCounter++;
if (spendCounter == 5)
{
Console.WriteLine("You can't save the money." + "\r\n" + "{0}", spendCounter);
break;
}
if (moneyAvailable < sum || moneyAvailable < 0)
{
moneyAvailable = 0;
}
else
{
moneyAvailable -= sum;
}
}
else if (action == "save")
{
counter++;
spendCounter = 0;
sum = double.Parse(Console.ReadLine());
moneyAvailable += sum;
}
if (moneyAvailable >= moneyForVacation)
{
Console.WriteLine("You saved the money for {0} days.", counter);
break;
}
}
}
}
}
Благодаря!