C# Q5) Re-order the following program statements so that they define the PrintHi
ID: 3766396 • Letter: C
Question
C#
Q5)
Re-order the following program statements so that they define the PrintHiLow() method that takes an unsorted array of names and another array of associated scores, and then prints out the names and scores together, ordering them from the highest to the lowest score, which means to sort them by score. For instance if the following arrays were passed to this method:
Then the following would be printed out by the method:
Jane: 95.0
Julie: 75.0
Joe: 35.0
Just re-order the lines. You don't have to add any lines. The entire method is already there:
names[i] + ": " + scores[i].ToString("#.0"));
List valueStrings = new List();
Console.WriteLine(str.Substring(6));
valueStrings.Add(scores[i].ToString("000.0") + ":" +
foreach (string str in valueStrings)
valueStrings.Reverse();
for (int i = 0; i < names.Length; ++i)
}
public static void PrintHiLow(string[] names, double[] scores) {
valueStrings.Sort();
Explanation / Answer
string names[]={"joe","jane","julie"};
names[i]+":"+scores[i].Tostring("#0"));
list valuestingd = new list();
console.writeLine(str.substring(6));
valuestrings.add(scores[i]tostirng("000.0"))+"."+
foreach(string str in valuestrings)
valuestrings.reverse();
for(int i=0;i<names.length;++i)
}
public static void printhilow(string[] names,double[] scores)
{
valuestrings.sort();
double score[]={35.0,75.0,95.0};
int high = highscore(score);
int low = lowscore(score);
console.writeline("high" + high +"low"+low);
}
static int highscore(double [] score)
{
int highscore =score[];
for(int i=0;i<score;i++)
{
if(score[i]>high)
{
high=score[i];
}
}
return high
}
static int lowscore(double [] score)
{
int lowscore =score[];
for(int i=0;i<score;i++)
{
if(score[i]<low)
{
low=score[i];
}
}
return low
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.