+ Нов въпрос
banko2 0 Точки

## New House . В Judg -a ми дава 20/100. Със 64 гладиоли и 128 лв. при мен излиза вярно.

using System;

namespace Upr_22._07._21
{
class Program
{
static void Main(string[] args)
{
double c = 0;

switch (flower)

{
case "Roses":
if (numFlower * 5 <= budget && numFlower > 80)
{
c = budget - numFlower * 5 * 0.9;
Console.WriteLine(\$"Hey, you have a great garden with {numFlower} {flower} and {c:f2} leva left.");
}

if (numFlower * 5 > budget)

{
c = numFlower * 5 - budget;

Console.WriteLine(\$"Not enough money, you need {c:f2} leva more.");
}

break;

case "Dahlias":
if (numFlower * 3.8 <= budget && numFlower > 90)
{
c = budget - numFlower * 3.8 * 0.85;

Console.WriteLine(\$"Hey, you have a great garden with {numFlower} {flower} and {c:f2} leva left.");
}

if (numFlower * 3.8 > budget)

{
c = numFlower * 3.8 - budget;

Console.WriteLine(\$"Not enough money, you need {c:f2} leva more.");
}

break;

case "Tulips":

if (numFlower * 2.8 <= budget && numFlower > 80)
{
c = budget - numFlower * 2.8 * 0.85;

Console.WriteLine(\$"Hey, you have a great garden with {numFlower} {flower} and {c:f2} leva left.");
}

if (numFlower * 2.8 > budget)

{
c = numFlower * 2.8 - budget;

Console.WriteLine(\$"Not enough money, you need {c:f2} leva more.");
}

break;

case "Narcissus":
if (numFlower * 3 <= budget && numFlower < 120)
{
c = budget - numFlower * 3 * 1.15;

Console.WriteLine(\$"Hey, you have a great garden with {numFlower} {flower} and {c:f2} leva left.");
}

if (numFlower * 3 > budget )

{
c = numFlower * 3 - budget;

Console.WriteLine(\$"Not enough money, you need {c:f2} leva more.");
}

break;

if (numFlower * 2.5 <= budget && numFlower < 80)
{
c = budget - numFlower * 2.5 * 1.2;

Console.WriteLine(\$"Hey, you have a great garden with {numFlower} {flower} and {c:f2} leva left.");
}

if (numFlower * 2.5 > budget )

{
c = numFlower * 2.5 - budget;

Console.WriteLine(\$"Not enough money, you need {c:f2} leva more.");
}

break;

}
}
}
}

Тагове:
0
svephoto 966 Точки

Здравей, banko2,

Мисля, че има нужда да направиш промени при проверките и изчисленията, като можеш да оптимизираш и решението като цяло. Ако искаш, виж как си го представих аз: https://pastebin.com/ZnftPk8Z. Надявам се да ти е от полза.

0
banko2 0 Точки

Благодаря

0
svephoto 966 Точки

Моля.

0
kitchens95658 -3 Точки

Thanks for response, I found a lot of interesting information here. very thankful and helpful.

MyBalanceNow

-3