write the program in C# provide a screenshot for the code and output rite a prog
ID: 3711222 • Letter: W
Question
write the program in C# provide a screenshot for the code and output
rite a program named ScoresComparison that allows a user to input four integer quiz scores ranging from 0 through 100. If no score is lower than any previous score, display a message that congratulates the user on making improvement, a display the scores in the order they were entered. If every score is lower than the previous one, display the scores in the order they were entered, display an appropriate message about the scores' descent, and then display the scores in the more desirable reverse order. If the scores neither increase nor decrease consistently, display an appropriate message along with the scores nd then doliery service to checkExplanation / Answer
Hi Dear,
Please find my implementation.
class ScoresComparison
{
static void Main(string[] args)
{
Console.WriteLine("Please enter your scores (would be 4 in number) separated by blank spaces, example- 90 100 70 89");
String scores = Console.ReadLine();
String[] scoresArray = scores.Split(' ');
String message = string.Empty;
bool[] descentArray = new bool[scoresArray.Length - 1];
for (int i = 0; i < scoresArray.Length-1; i++)
{
if (Convert.ToInt32(scoresArray[i]) > Convert.ToInt32(scoresArray[i + 1]))
{
descentArray[i] = false;
}
else
{
descentArray[i] = true;
}
}
bool descent = false;
if (descentArray.Contains(true))
{
if (descentArray.Contains(false))
{
message = "You are doing a good job but can push yourself more. All the best!";
}
else
{
message = "Congratulations on your constant progress";
}
}
else
{
message = "Your marks are constantly decreasing. You should focus more on your studies as you have the potential to do better than this!";
descent = true;
}
Console.WriteLine("Your entered scores are: " + scores);
Console.WriteLine(message);
if (descent)
{
Array.Sort(scoresArray);
string temp = string.Empty;
foreach (string str in scoresArray)
{
temp = temp + " " + str;
}
Console.WriteLine("Your scores should have been like this!" + temp);
}
Console.ReadLine();
}
}
// the last Console.ReadLine() is there to let the console window stay and not vanish after executing the program
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.