Проблем със задачата Fruit Shop
Здравейте! В judge ми дава 22/100.. Някои би ли ми помогнал да разбера къде греша.. Ще съм много благодарна :)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _fruitShop
{
class Program
{
static void Main(string[] args)
{
string fruit = Console.ReadLine().ToLower();
string day = Console.ReadLine().ToLower();
double kolichestvo = double.Parse(Console.ReadLine());
double price = -1.0;
if(day=="Monday" || day=="Tuesday" || day=="Wednesday" || day=="Thursday" || day=="Friday")
{
if (fruit == "banana")
{
price = kolichestvo * 2.50;
Console.WriteLine("{price:F2}");
}
else if (fruit == "apple")
{
price = kolichestvo * 1.20;
Console.WriteLine("{price:F2}");
}
else if (fruit == "orange")
{
price = kolichestvo * 0.85;
Console.WriteLine("{price:F2}");
}
else if (fruit == "grapefruit")
{
price = kolichestvo * 1.45;
Console.WriteLine("{price:F2}");
}
else if (fruit == "kiwi")
{
price = kolichestvo * 2.70;
Console.WriteLine("{price:F2}");
}
else if (fruit == "pineapple")
{
price = kolichestvo * 5.50;
Console.WriteLine("{price:F2}");
}
else if (fruit == "grapes")
{
price = kolichestvo * 3.85;
Console.WriteLine("{price:F2}");
}
else Console.WriteLine("error");
}
if(day=="Saturday" || day=="Sunday")
{
if (fruit == "banana")
{
price = kolichestvo * 2.70;
Console.WriteLine("{price:F2}");
}
else if (fruit == "apple")
{
price = kolichestvo * 1.25;
Console.WriteLine("{price:F2}");
}
else if (fruit == "orange")
{
price = kolichestvo * 0.90;
Console.WriteLine("{price:F2}");
}
else if (fruit == "grapefruit")
{
price = kolichestvo * 1.60;
Console.WriteLine("{price:F2}");
}
else if (fruit == "kiwi")
{
price = kolichestvo * 3.00;
Console.WriteLine("{price:F2}");
}
else if (fruit == "pineapple")
{
price = kolichestvo * 5.60;
Console.WriteLine("{price:F2}");
}
else if (fruit == "grapes")
{
price = kolichestvo * 4.20;
Console.WriteLine("{price:F2}");
}
else
Console.WriteLine("error");
}
else
{
Console.WriteLine("error");
}
}
}
}
Много ти благодаря!!
Моля те пробвай, защото след поправките на мен пак не ми се получава.
тая проверка дали е if или if else не влияе на кода като цяло :Д
Ето коригиран код: