Fishing boat
Здравейте,колеги.Решавам задачата по 2 начина .И при 2та ми е ок ,но в Judge при единия вариант ми дава 60/100.А при мене на компа си показва верни резулатите от примерите:
при вариант 1 ми дава 60/100.
ето вариант 1:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace fishboats
{
class Program
{
static void Main(string[] args)
{
int budget = int.Parse(Console.ReadLine());
string season = Console.ReadLine();
int countfishermen = int.Parse(Console.ReadLine());
double price = 0;
double money = 0;
switch (season)
{
case "Spring":
price = 3000;
break;
case "Summer":
price = 4200;
break;
case "Autumn":
price = 4200;
break;
case "Winter":
price = 2600;
break;
}
if (countfishermen <= 6)
{
money = price - price * 0.1;
}
else if (countfishermen >= 7 && countfishermen <= 11)
{
money = price - price * 0.15;
}
else if (countfishermen >= 12)
{
money = price - price * 0.25;
}
if (countfishermen % 2 == 0 && season != "Autumn")
{
money = price - price * 0.05;
}
else
{
money = money;
}
if (money <= budget)
{
Console.WriteLine($"Yes! You have {(budget - money):f2} leva left.");
}
else
{
Console.WriteLine($"Not enough money! You need {(money - budget):f2} leva.");
}
}
}
}
ето вариант 2:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace fishing_boat
{
class Program
{
static void Main(string[] args)
{
int budget = int.Parse(Console.ReadLine());
string season = Console.ReadLine();
int countfishermen = int.Parse(Console.ReadLine());
double priseship = 0;
switch (season)
{
case "Spring":
priseship = 3000;
if (countfishermen<=6)
{
priseship = priseship - priseship * 0.1;
}
else if (countfishermen>=7 && countfishermen<=11)
{
priseship = priseship - priseship * 0.15;
}
else if (countfishermen>=12)
{
priseship = priseship - priseship * 0.25;
}
if (countfishermen % 2 == 0)
{
priseship = priseship - priseship * 0.05;
}
else
{
priseship = priseship;
}
if (budget>=priseship)
{
Console.WriteLine($"Yes! You have {(budget-priseship):f2} leva left.");
}
else
{
Console.WriteLine($"Not enough money! You need {(priseship-budget):f2} leva.");
}
break;
case "Summer":
priseship = 4200;
if (countfishermen <= 6)
{
priseship = priseship - priseship * 0.1;
}
else if (countfishermen >= 7 && countfishermen <= 11)
{
priseship = priseship - priseship * 0.15;
}
else if (countfishermen >= 12)
{
priseship = priseship - priseship * 0.25;
}
if (countfishermen % 2 == 0)
{
priseship = priseship - priseship * 0.05;
}
else
{
priseship = priseship;
}
if (budget >= priseship)
{
Console.WriteLine($"Yes! You have {(budget - priseship):f2} leva left.");
}
else
{
Console.WriteLine($"Not enough money! You need {(priseship - budget):f2} leva.");
}
break;
case "Autumn":
priseship = 4200;
if (countfishermen <= 6)
{
priseship = priseship - priseship * 0.1;
}
else if (countfishermen >= 7 && countfishermen <= 11)
{
priseship = priseship - priseship * 0.15;
}
else if (countfishermen >= 12)
{
priseship = priseship - priseship * 0.25;
}
if (budget >= priseship)
{
Console.WriteLine($"Yes! You have {(budget - priseship):f2} leva left.");
}
else
{
Console.WriteLine($"Not enough money! You need {(priseship - budget):f2} leva.");
}
break;
case "Winter":
priseship = 2600;
if (countfishermen <= 6)
{
priseship = priseship - priseship * 0.1;
}
else if (countfishermen >= 7 && countfishermen <= 11)
{
priseship = priseship - priseship * 0.15;
}
else if (countfishermen >= 12)
{
priseship = priseship - priseship * 0.25;
}
if (countfishermen % 2 == 0)
{
priseship = priseship - priseship * 0.05;
}
else
{
priseship = priseship;
}
if (budget >= priseship)
{
Console.WriteLine($"Yes! You have {(budget - priseship):f2} leva left.");
}
else
{
Console.WriteLine($"Not enough money! You need {(priseship - budget):f2} leva.");
}
break;
}
}
}
}