Console.WriteLine("SUPABRIKS FESTIVAL COMPETITION POINTS HELPER");
bool isFinished = false;
int numberOfBricks = 0;
int timeTaken = 0;
float scoreOne = 0;
float scoreTwo = 0;
float scoreThree = 0;
float scoreSum = 0;
float penaltyFactor = 0;
int totalPoints = 0;
while (!isFinished)
{
Console.WriteLine();
//All logic must go in here
Console.Write("Enter the team name: ");
bool isValidTeamName = false;
string teamName = Console.ReadLine();
while (!isValidTeamName)
{
if (string.IsNullOrWhiteSpace(teamName))
{
Console.WriteLine("Team name cannot be empty. Please enter a valid team name.");
teamName = Console.ReadLine();
}
else
{
isValidTeamName = true;
}
}
Console.WriteLine();
Console.Write("Enter the number of bricks used. ");
bool isValidNumberOfBricks = false;
string numberBriksInput = Console.ReadLine();
while (!isValidNumberOfBricks)
{
if (!int.TryParse(numberBriksInput, out numberOfBricks) || numberOfBricks <= 0 || numberOfBricks > 1000)
{
Console.WriteLine("Please enter a valid positive integer for the number of bricks.");
numberBriksInput = Console.ReadLine();
}
else
{
isValidNumberOfBricks = true;
}
}
Console.Write("Enter the time taken (in minutes). ");
bool isValidTimeTaken = false;
string timeTakenInput = Console.ReadLine();
while (!isValidTimeTaken)
{
if (!int.TryParse(timeTakenInput, out timeTaken) || timeTaken <= 0)
{
Console.WriteLine("Please enter a valid positive integer for the time taken.");
timeTakenInput = Console.ReadLine();
}
else
{
isValidTimeTaken = true;
}
}
Console.WriteLine();
Console.WriteLine("Enter Judge #1's score.");
bool isValidScoreOne = false;
string scoreOneInput = Console.ReadLine();
while (!isValidScoreOne)
{
if (!float.TryParse(scoreOneInput, out scoreOne) || scoreOne < 0 || scoreOne > 10)
{
Console.WriteLine("Please enter a valid score between 0 and 10 for Judge #1.");
scoreOneInput = Console.ReadLine();
}
else
{
isValidScoreOne = true;
}
}
Console.WriteLine("Enter Judge #2's score.");
bool isValidScoreTwo = false;
string scoreTwoInput = Console.ReadLine();
while (!isValidScoreTwo)
{
if (!float.TryParse(scoreTwoInput, out scoreTwo) || scoreTwo < 0 || scoreTwo > 10)
{
Console.WriteLine("Please enter a valid score between 0 and 10 for Judge #2.");
scoreTwoInput = Console.ReadLine();
}
else
{
isValidScoreTwo = true;
}
}
Console.WriteLine("Enter Judge #3's score.");
bool isValidScoreThree = false;
string scoreThreeInput = Console.ReadLine();
while (!isValidScoreThree)
{
if (!float.TryParse(scoreThreeInput, out scoreThree) || scoreThree < 0 || scoreThree > 10)
{
Console.WriteLine("Please enter a valid score between 0 and 10 for Judge #3.");
scoreThreeInput = Console.ReadLine();
}
else
{
isValidScoreThree = true;
}
}
if (timeTaken > 240)
{
penaltyFactor = 1.3f;
}
else if (timeTaken > 180)
{
penaltyFactor = 1.1f;
}
else
{
penaltyFactor = 1.0f;
}
scoreSum = scoreOne + scoreTwo + scoreThree;
totalPoints = (int)(scoreSum * numberOfBricks / penaltyFactor);
Console.WriteLine($"{teamName} + total points: {totalPoints}");
Console.WriteLine("Would you like to enter another team score? (Y/N)");
string userInput = Console.ReadLine();
if (userInput.ToUpper() == "N")
{
isFinished = true;
}
}