This is Starting out with Visual C# 2012((((( just i need design form and code p
ID: 3803446 • Letter: T
Question
This is Starting out with Visual C# 2012((((( just i need design form and code poth of them)))))
In this assignment you will use excel to process the scores of a diving competition. In the next assignment you will solve the same problem using C#. The diving works as follows: A set of judges score each dive from 0 to 10 in steps of 0.5. The total score for a dive is obtained by discarding the lowest and highest of the judges' scores, adding the remaining scores, and multiplying the result by the degree of difficulty for that dive. A diver's overall score is computed by adding together his/her total scores for each dive The first line of the file contains three integers: the number of divers in the competition the number of rounds in the competition and the number of judges the competition. For initialization purposes the diver's names are giving one per line. Next in the file are the judges' scores for each round. Each line contains the name of the diver, the degree of difficulty followed by the judges' scores for that dive The following is an example a data file. The competition consists of three divers, three rounds and five judges.Explanation / Answer
Write main function as seperate function and use wherever u need?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
System.IO.StreamReader myFile =
new System.IO.StreamReader("D: avi\Cheg\diversRatings.txt");
string line;
int count = 0;
int ndivers = 0;
int round = 0;
int judges = 0;
string[] diverNames = null;
float[] scores = null;
float[] tempArr = null;
string[] tokens = null;
int index = 0;
float diff = 0;
while ((line = myFile.ReadLine()) != null)
{
if (!string.IsNullOrEmpty(line.Trim()))
{
// Console.WriteLine("1" + line);
if(count == 0)
{
tokens = line.Split(' ');
ndivers = Int32.Parse(tokens[0].Trim());
diverNames = new string[ndivers];
round = Int32.Parse(tokens[0].Trim());
judges = Int32.Parse(tokens[0].Trim());
scores = new float[ndivers];
for (Int16 i = 0; i < ndivers; i++)
scores[i] = 0;
} else if(count > 0 && count <= ndivers)
{
diverNames[count - 1] = line.Trim();
} else
{
tempArr = new float[judges];
tokens = line.Split(' ');
for(Int32 i = 0; i < diverNames.Length; i++)
{
if (diverNames[i].Equals(tokens[0].Trim()))
index = i;
}
diff = float.Parse(tokens[1].Trim());
float temp = 0;
float min = 0;
float max = 0;
float sum = 0;
for(Int32 i = 2; i < tokens.Length; i++)
{
temp = float.Parse(tokens[i].Trim());
if(i == 2)
{
min = temp;
max = temp;
}
if (min > temp)
min = temp;
if (max < temp)
max = temp;
sum += temp;
}
sum = sum - min - max;
scores[index] += sum * diff;
}
}
count++;
}
myFile.Close();
for (Int32 i = 0; i < ndivers; i++)
Console.WriteLine(diverNames[i]+":"+scores[i]);
// Suspend the screen.
Console.ReadLine();
}
}
}
--inputfille---
3 3 5
GoodWin
Kronner
Swatzel
GoodWin 2.3 7.5 6.0 8.5 7.0 6.5
Kronner 2.0 5.0 7.5 8.0 7.0 8.5
Swatzel 3.2 6.0 8.0 7.0 5.0 9.0
Kronner 2.0 5.0 7.5 8.0 7.0 8.5
Swatzel 3.2 6.0 8.0 7.0 5.0 9.0
GoodWin 2.3 7.5 6.0 8.5 7.0 6.5
GoodWin 2.3 7.5 6.0 8.5 7.0 6.5
Kronner 2.0 5.0 7.5 8.0 7.0 8.5
Swatzel 3.2 6.0 8.0 7.0 5.0 9.0
---output--------------
GoodWin:144.9
Kronner:135
Swatzel:201.6
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.