viktorv19 16 Точки

## Easter Decoration

https://softuni.bg/downloads/svn/programming-basics-v4/course-directories/may-2019/2019-03/Exam/06.%20Easter%20Decoration.pdf това е задачата може ли малко помощ. Ако може някай да ми обясни къде ми е грешката и как да я поправя ще съм много благодарен!

using System;

namespace EeasterDecoration
{
class Program
{
static void Main(string[] args)
{

int customerNumber = int.Parse(Console.ReadLine());
string command = string.Empty;
double wholeSum = 0;
for (int i = 0; i < customerNumber; i++)
{
double basket = 0;
double wreath = 0;
double chocolateBunny = 0;
while (command != "Finish")
{
if (command == "basket")
{
}
else if (command == "wreath")
{
wreath++;
}
else if (command == "chocolate bunny")
{
chocolateBunny++;
}

}
double productNumber = basket + wreath + chocolateBunny;
double price = basket * 1.50 + wreath * 3.80 + chocolateBunny * 7;
if (productNumber % 2 == 0)
{
price = price - (price * 0.2);
}
Console.WriteLine(\$"You purchased {productNumber} items for {price:f2} leva.");
wholeSum += price;

}
Console.WriteLine(\$"Average bill per client is: {(wholeSum / customerNumber):f2} leva.");
}
}
}

Тагове:
0
29/11/2019 16:03:51
silenzio 56 Точки

Привет,

Ето твоят код преработен:

using System;

namespace EeasterDecoration
{
class Program
{
static void Main(string[] args)
{

int customerNumber = int.Parse(Console.ReadLine());

double wholeSum = 0;

for (int i = 0; i < customerNumber; i++)
{
double price=0;
double productNumber=0;
double basket = 0;
double wreath = 0;
double chocolateBunny = 0;
string  command = Console.ReadLine();
while (command != "Finish")
{

if (command == "basket")
{
}
else if (command == "wreath")
{
wreath++;
}
else if (command == "chocolate bunny")
{
chocolateBunny++;
}
productNumber = basket + wreath + chocolateBunny;
price = basket * 1.50 + wreath * 3.80 + chocolateBunny * 7;

}

if (productNumber % 2 == 0)
{
price = price - (price * 0.2);
}
Console.WriteLine(\$"You purchased {productNumber} items for {price:f2} leva.");
wholeSum += price;

}
Console.WriteLine(\$"Average bill per client is: {(wholeSum / customerNumber):f2} leva.");
}
}
}

0