Question: I am working on a program that allows the user to enter scores and add them to an array list and once the user clicks
I am working on a program that allows the user to enter scores and add them to an array list and once the user clicks the button to display the scores it should display sorted list of scored.
This is the current code that i have and i am trying to fix the code.
/////////////////////////////////////
public partial class frmScoreCalculatorList : Form { public frmScoreCalculatorList() { InitializeComponent(); } int total = 0; int count = 0; List
private void btnAdd_Click(object sender, EventArgs e) { int score = Convert.ToInt32(txtScore.Text); myData.Add(score); total += score; count += 1; int average = total / count; txtScoreTotal.Text = total.ToString(); txtScoreCount.Text = count.ToString(); txtAverage.Text = average.ToString(); txtScore.Focus(); }
private void btnDisplay_Click(object sender, EventArgs e) { myData.Sort(); string scoresString = ""; foreach (int i in myData) if (i != 0) { scoresString += i.ToString() + " "; } MessageBox.Show(scoresString, "Sorted Scores"); txtScore.Focus(); }
private void btnClearScores_Click(object sender, EventArgs e) { total = 0; txtScore.Text = ""; txtScoreTotal.Text = ""; txtScoreCount.Text = ""; txtAverage.Text = ""; txtScore.Focus(); myData = new List
private void btnExit_Click(object sender, EventArgs e) { this.Close(); } }
///////////////////////////////////////////////////////////////////////////////////
> Delete the class variable for the score count. This count is not needed anymore, why not? I am trying to figure out how to use the count feature if i am going to delete the count variable.
> Modify the Click event handler for the Add button so it adds to the list the score thats entered by the user. In addition, delete the statement that increments the score count variable you just deleted.
> Modify the Click event handler for the Display Scores button so it sorts the scores in the list and then displays them in a dialog box. Modify the dialog box so that it shows the count of the number of elements in the list. How can you determine the count of these elements given that we are no longer tracking this count.

Score Calculator Score Add Score Total: Average Scores gear Scores Exit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
