Задача " Shopping"
Здравейте група, някой ще може ли да погледне ако има време решението ми на задачата Shopping. До if-a ми излиза вярно, но нещо явно бъркам в else-a.
https://judge.softuni.bg/Contests/Practice/Index/1745#3 - Можете да видите условието на задачата.
Моето творение:
using System;
namespace Shopping
{
class Program
{
static void Main(string[] args)
{
double budget = double.Parse(Console.ReadLine());
int videoCards = int.Parse(Console.ReadLine());
int processors = int.Parse(Console.ReadLine());
int ram = int.Parse(Console.ReadLine());
double videocardPrice = 250;
double totalVideocardPrice = videoCards * videocardPrice;
double processorsPrice = totalVideocardPrice * 0.35;
double totalProcessorsPrice = processors * processorsPrice;
double ramPrice = totalVideocardPrice * 0.10;
double totalRamPrice = ram * ramPrice;
if (videoCards > processors)
{
double finalSum = totalVideocardPrice + totalProcessorsPrice + totalRamPrice;
double discount = finalSum * 0.15;
double finalDiscountSum = finalSum - discount;
double moneyLeft = budget - finalDiscountSum;
Console.WriteLine($"You have{moneyLeft:f2} leva left ");
}
else
{
double finalSum = totalVideocardPrice + totalProcessorsPrice + totalRamPrice;
double discount = finalSum * 0.15;
double finalDiscountSum = finalSum - discount;
double moneyNeed = finalSum - budget;
Console.WriteLine($"Not enough money! You need {moneyNeed:f2} leva more!");
}
}
}
}
Ок, мерси. Сега ще се опитам да го оправя.