+ Нов въпрос

## 07. Toy Shop

Като Run-на програмата излиза отговора точно, както са описали в задачата, а Judge Ми дава 30/100

Къде е грешката според Вас?

using System;

namespace _07._Toy_Shop
{
class Program
{
static void Main(string[] args)
{
double excursionprice = double.Parse(Console.ReadLine());
int numOfPuzzles = int.Parse(Console.ReadLine());
int numOfDolls = int.Parse(Console.ReadLine());
int numOfBears = int.Parse(Console.ReadLine());
int numOfMinions = int.Parse(Console.ReadLine());
int numOfTrucks = int.Parse(Console.ReadLine());

int orderedToys = numOfBears + numOfDolls + numOfMinions + numOfPuzzles + numOfPuzzles + numOfTrucks;

double priceOfPuzzle = 2.6;
double priceOfDoll = 3;
double priceOfBear = 4.1;
double priceOfMinion = 8.2;
double priceOfTruck = 2;

double earningPuzzles = numOfPuzzles * priceOfPuzzle;
double earningDolls = numOfDolls * priceOfDoll;
double earningBears = numOfBears * priceOfBear;
double earningMinions = numOfMinions * priceOfMinion;
double earningTrucks = numOfTrucks * priceOfTruck;
double pirceOfOrder = earningTrucks + earningPuzzles + earningMinions + earningDolls + earningBears;
double priceAfterRent = pirceOfOrder * 0.9;

if (orderedToys >= 50)
{
double discountPrice = priceAfterRent * 0.75;

double remainingMoney = discountPrice - excursionprice;

if (remainingMoney >= excursionprice)
{
Console.WriteLine(\$"Yes! {remainingMoney:f2} lv left.");
}
else
{
double lackingMoney = excursionprice - priceAfterRent;
Console.WriteLine(\$"Not enough money! {lackingMoney:f2} lv needed.");
}
}
else
{
double remainingMoney = priceAfterRent - excursionprice;
if (remainingMoney >= excursionprice)
{
Console.WriteLine(\$"Yes! {remainingMoney:f2} lv left.");
}
else
{
double lackingMoney = excursionprice - priceAfterRent;
Console.WriteLine(\$"Not enough money! {lackingMoney:f2} lv needed.");
}
}

}
}
}

Тагове:
0
poli_rk 6 Точки

ето моето решение на C#:

https://pastebin.com/t7LUEPR3

Това, което виждам е, че 10% намаление за наема трябва да е след 25% отстъпка + имаш доста допълнителни if проверки.

0

Сега ще го погледна.

Новото ми решение докара 70/100. Дали грешката идва от тези допълнителни if проверки?

Благодаря!

using System;

namespace TOYSHOP.vol3
{
class Program
{
static void Main(string[] args)
{
double tripPrice = double.Parse(Console.ReadLine());
int numOfPuzzels = int.Parse(Console.ReadLine());
int numOfDolls = int.Parse(Console.ReadLine());
int numOfBears = int.Parse(Console.ReadLine());
int numOfMinions = int.Parse(Console.ReadLine());
int numOfTrucks = int.Parse(Console.ReadLine());

int numOfToys = numOfBears + numOfDolls + numOfMinions + numOfMinions + numOfTrucks;

double totalPrice = numOfPuzzels * 2.6 + numOfDolls * 3 + numOfBears * 4.1 + numOfMinions * 8.2 + numOfTrucks * 2;

if (numOfToys >= 50)
{
double finalPrice = totalPrice * 0.75;
double profit = finalPrice * 0.9;
if (profit >= tripPrice)
{
double remainingMoney = profit - tripPrice;
Console.WriteLine(\$"Yes! {remainingMoney:f2} lv left.");
}
else
{
double lackingMoney = tripPrice - profit;
Console.WriteLine(\$"Not enough money! {lackingMoney:f2} lv needed.");
}
}
else
{
double finalPrice = totalPrice;
double earnings = totalPrice * 0.9;
if (earnings >= tripPrice)
{
double remainingMoney = earnings - tripPrice;
Console.WriteLine(\$"Yes! {remainingMoney:f2} lv left.");
}
else
{
double lackingMoney = tripPrice - earnings;
Console.WriteLine(\$"Not enough money! {lackingMoney:f2} lv needed.");
}
}
}
}
}

0