Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Need help with 2-D arrays

$
0
0

this is a homework question

  1. Write an application to calculate student grades for a group project.
  2. Create a text file to store names of 5 students, line by line.
  3.  In a separate file enter peer evaluations from 0 to 1.0.
  4. Enter these numbers for evals:

1.0,  0.8,  0.9,  1.0,   0.6

0.2,  0.9,   0.5,   0.6,   0.7

0.5,  1.0,   1.0,  1.5,  0.9

0.9,  0.9,   0.9,    1.0,   1.0

1.0,  0.9,  1.0 ,   0.8,   0.9

This means that student 1 gave 1.0 eval for him- herself, 0.8 for student 2, 0.9 for student 3 etc. Student 2 gave 0.2 for student 1, 0.9 for him- herself, 0.5 for student 3 etc.

Read these into a 2-dimensional array.

If any of the values is greater than 1.0, set them to 1.0.

The program should calculate the average eval for a student.

While doing so, the program should ignore evals that student gave to him-herself.

Populate a list box with student names when the form loads.

The user should enter a project grade (same for everyone) in  a textbox.

 Then the user can select a student from a list and click “Calculate” button.

 The program should display the project grade for that student by multiplying average eval by the grade for the whole group (project grade).

--------------------------

I got the naming names in ListBox but after that I want to calculate the average of the 2-D arrays whenever the user click on the names.

private void Form1_Load(object sender, EventArgs e)
        {
            //read namesFile and show it on listbox
            StreamReader namesFile;
            namesFile = File.OpenText("Names.txt");
            while (!namesFile.EndOfStream)
            {
                studentsNamesListBox.Items.Add(namesFile.ReadLine());
            }



 StreamReader scoresFile;
           scoresFile = File.OpenText("Scores.txt");

   const int ROWS = 5;
            const int COLS = 5;
            int[,] iArray = new int[ROWS,COLS];
            int col;
            int row;
            int eval;

            //selected names in the listbox should match the average evaluation score of the name
            if (studentsNamesListBox.SelectedIndex != 1)
            {
                for (col = 0; col < COLS; col++)     //sum up the column only
                {
                    if (row != col)                 //ignore student own evaluation
                    {
                        eval = Math.Max(eval, 1);        //max number is 1
                    }

                }
            }

I am not sure how it is suppose to be, can someone clarify?



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>