03. Restaurant Discount
Някой има ли проблем с втория нулев тест ? При 90 човека и пакет Platinum, според теста по -подходяща е по - малката по капацитет Terrace!
Само за пояснение това е трета задача от C# Conditional Statements and Loops - Exercises (Practice)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _03.RestaurantDiscount
{
class Program
{
static void Main(string[] args)
{
int groupSize = int.Parse(Console.ReadLine());
string servicePackage = Console.ReadLine();
double suitablePrice = 0.0d;
double priceOfPackage = 0.0d;
double discount = 0.0d;
string hall = null;
if (groupSize > 120) Console.WriteLine("We do not have an appropriate hall.");
else
{
if (groupSize > 75)
{
hall = "Great Hall";
switch (servicePackage)
{
case "Normal": discount = 0.95; priceOfPackage = 500; break;
case "Gold": discount = 0.9; priceOfPackage = 750; break;
case "Platinum": discount = 0.85; priceOfPackage = 1000; break;
}
suitablePrice = (7500 + priceOfPackage) * discount;
}
else if (groupSize > 50 && groupSize <= 75)
{
hall = "Terrace";
switch (servicePackage)
{
case "Normal": discount = 0.95; priceOfPackage = 500; break;
case "Gold": discount = 0.9; priceOfPackage = 750; break;
case "Platinum": discount = 0.85; priceOfPackage = 1000; break;
}
suitablePrice = (5000 + priceOfPackage) * discount;
}
else if (groupSize <= 50)
{
hall = "Small Hall";
switch (servicePackage)
{
case "Normal": discount = 0.95; priceOfPackage = 500; break;
case "Gold": discount = 0.9; priceOfPackage = 750; break;
case "Platinum": discount = 0.85; priceOfPackage = 1000; break;
}
suitablePrice = (2500 + priceOfPackage) * discount;
}
double pricePerPerson = Math.Round(suitablePrice / groupSize * 1.0, 2);
Console.WriteLine("We can offer you the {0}", hall);
Console.WriteLine("The price per person is {0}$", pricePerPerson);
}
}
}
}
Единият тест не минава 85/100; Някой,ако може да помогне и вижда грешка.Благодаря :)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3ta_zad
{
class Program
{
static void Main(string[] args)
{
var hora = int.Parse(Console.ReadLine());
string package = Console.ReadLine();
var pricesmallHall = 2500;
var priceTerrace = 5000;
var pricegreatHall = 10000;
if (hora <= 50 && package == "Normal")
{
var cenasPaket = pricesmallHall + 500;
var otstupkaCena = cenasPaket - (cenasPaket * 0.05);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Small Hall");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if (hora <= 50 && package == "Gold")
{
var cenasPaket = pricesmallHall + 750;
var otstupkaCena = cenasPaket - (cenasPaket * 0.1);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Small Hall");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if (hora <= 50 && package == "Platinum")
{
var cenasPaket = pricesmallHall + 1000;
var otstupkaCena = cenasPaket - (cenasPaket * 0.15);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Small Hall");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if ((hora > 50 && hora <= 100) && package == "Normal")
{
var cenasPaket = priceTerrace + 500;
var otstupkaCena = cenasPaket - (cenasPaket * 0.05);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Terrace");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if ((hora > 50 && hora <= 100) && package == "Gold")
{
var cenasPaket = priceTerrace + 750;
var otstupkaCena = cenasPaket - (cenasPaket * 0.1);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Terrace");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if ((hora > 50 && hora <= 100) && package == "Platinum")
{
var cenasPaket = priceTerrace + 1000;
var otstupkaCena = cenasPaket - (cenasPaket * 0.15);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Terrace");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if ((hora > 100 && hora <= 120) && package == "Normal")
{
var cenasPaket = pricegreatHall + 500;
var otstupkaCena = cenasPaket - (cenasPaket * 0.05);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Great Hall");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if ((hora > 100 && hora <= 120) && package == "Gold")
{
var cenasPaket = pricegreatHall + 750;
var otstupkaCena = cenasPaket - (cenasPaket * 0.1);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Great Hall");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if ((hora > 100 && hora <= 120) && package == "Platinum")
{
var cenasPaket = pricegreatHall + 1000;
var otstupkaCena = cenasPaket - (cenasPaket * 0.15);
var naChovek = otstupkaCena / hora;
Console.WriteLine("We can offer you the Great Hall");
Console.WriteLine($"The price per person is {naChovek:f2}$");
}
else if (hora > 120)
{
Console.WriteLine("We do not have an appropriate hall.");
}
}
}
}
цената на голямата зала мисля че е 7500
ето и едно от мен:
https://github.com/spzvtbg/TechModuleProgrammingFundamentals23.05.2017/blob/master/02.ConditionalStatementsAndLoopsExercises/03.%20Restaurant%20Discount/RestaurantDiscount.cs
Колега(Стефчо),пишеш прекалено много излишен код и става трудно четим,погледни мойто решение и следващият път няма да е нужно да пишеш толква много излишен код,нядявам се да съм бил полезен :)
Успех!