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);
}
}
}
}
Някой помощ, че ми изкарва 71/100 точки в judge, а не мога си намеря грешката от доста време.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _3.Problem
{
class Program
{
static void Main()
{
int group = int.Parse(Console.ReadLine());
string typeOfPackage = Console.ReadLine();
string hall = null;
if (group <= 50)
{
hall = "Small Hall";
if (typeOfPackage == "Normal")
{
double price = 2700.0 / group;
Console.WriteLine("We can offer you the {0:f2}",hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
else if (typeOfPackage == "Gold")
{
double price = 2925.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
else if (typeOfPackage == "Platinum")
{ double price = 3150.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
}
else if (group > 50 & group <= 100)
{
hall = "Terrace";
if (typeOfPackage == "Normal")
{
double price = 5275.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
else if (typeOfPackage == "Gold")
{
double price = 5175.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
else if (typeOfPackage == "Platinum")
{
double price = 5100.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
}
else if (group > 100 & group <= 120)
{
hall = "Great Hall";
if (typeOfPackage == "Normal")
{
double price = 7600.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
else if (typeOfPackage == "Gold")
{
double price = 7425.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
else if (typeOfPackage == "Platinum")
{
double price = 7225.0 / group;
Console.WriteLine("We can offer you the {0:f2}", hall);
Console.WriteLine("The price per person is {0:f2}$", price);
}
}
else if (group > 120 || group <=0)
{
Console.WriteLine("We do not have an appropriate hall.");
}
}
}
}
Здравейте! :)
И аз се затруднявам на тази задача. В judge ми дава 71/100.
Ако може някой да ми посочи къде греша ще съм му много благодарна.
Ето го моя код:
https://pastebin.com/TYyYixMF
Благодаря предварително!!!
Променливата ти priceHall трябва да е double, за да може да получиш цени, които не са цяло число.