Answer:
Check the explanation
Explanation:
As per requirement submitted above kindly find below solution.
Here new console application in C# is created using visual studio 2019 with name "HighScoreApp". This application contains a class with name "Program.cs".Below is the details of this class.
Program.cs :
//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace HighScoreApp
{
class Program //C# class
{
//entry point of the program , Main() method
static void Main(string[] args)
{
//declaring variable to store number of score
int numberOfScores = 0;
//using while loop
while(numberOfScores<=0)
{
//asking user number of high scores
Console.WriteLine("Enter number of high scores : ");
//reading input
numberOfScores = int.Parse(Console.ReadLine());
}
//declaring array with number of scores
int[] scores = new int[numberOfScores];
//asking user high scores using for loop
for (int i = 0; i < scores.Length; i++)
{
//asking high scores
Console.WriteLine("Enter score "+(i+1)+" : ");
//reading score
scores[i] = int.Parse(Console.ReadLine());
}
Console.WriteLine();//used for new line
Console.WriteLine("High Scores -Unsorted");
//call function to print each element
PrintArray(scores);
//call method to sort the array elements
scores = SortArrayHighToLow(scores);
Console.WriteLine();//used to print new line
Console.WriteLine("High Scores-Sorted");
PrintArray(scores);//call method to print array elements
Console.SetCursorPosition(0, Console.WindowHeight - 1);
Console.WriteLine("Press ENTER to continue....");
Console.ReadLine();
}
//method to print the array
public static void PrintArray(int [] scoresArray)
{
//using for loop , print each score
for (int i = 0; i < scoresArray.Length; i++)
{
Console.WriteLine(scoresArray[i]);//print each high score
}
}
//method to sort the array
public static int [] SortArrayHighToLow(int[] scoresArray)
{
Array.Sort(scoresArray);
return scoresArray;
}
}
}
==================================
Output :Run application using F5 and will get the screen as shown below
Kindly check the below Screenshot for Output :Program.cs