+ Нов въпрос
LilijaVB 5 Точки

## Проблем със задача 03.Flowers от Programming Basics with C# (Conditional Statements Advanced - Moore Exercises)

Здравейте! Имам проблем със следния код: https://pastebin.com/zMTUUsEz . В judge ми дава 62/100, но не мога да разбера от къде идва проблемът.

Ето и условието на задачата: https://pasteboard.co/ZxRHZkixrP3o.png  ,  https://pasteboard.co/hGYI6vakoNFZ.png

Тагове:
0
Axiomatik 1581 Точки

Two final validations (flowers more than 20) didn't work because of missing brackets, otherwise good code.

100% =>

``                if ((flowers > 20) && (season == "Spring" || season == "Summer" || season == "Autumn" || season == "Winter"))``

``                if (((chrysanthemums + roses + tulips) > 20) && (season == "Spring" || season == "Summer" || season == "Autumn" || season == "Winter"))``

:-)

Refactored version:

``````using System;

namespace _03.Flowers
{
class Program
{
static void Main(string[] args)
{

int workPrice = 2;
double chrysanthemumsPrice = 0.00;
double rosesPrice = 0.00;
double tulipssPrice = 0.00;

switch (season)
{
case "Spring":
case "Summer":
chrysanthemumsPrice = 2.00;
rosesPrice = 4.10;
tulipssPrice = 2.50;
break;
case "Autumn":
case "Winter":
chrysanthemumsPrice = 3.75;
rosesPrice = 4.50;
tulipssPrice = 4.15;
break;
}

double price = chrysanthemums * chrysanthemumsPrice + roses * rosesPrice + tulips * tulipssPrice;
int flowers = chrysanthemums + roses + tulips;

if(day == "Y")
{
price *= 1.15;
}

if (tulips > 7 && season == "Spring")
{
price -= price * 0.05;
}
else if (roses >= 10 && season == "Winter")
{
price -= price * 0.1;
}

if (flowers > 20)
{
price -= price * 0.20;
}

double finalPrice = price + workPrice;
Console.WriteLine(\$"{finalPrice:f2}");
}
}
}
``````

0
LilijaVB 5 Точки

Thank you! :)

1