Question: In Microsoft Visual Studio 2015 and using C# programming, how do you code the following in the easiest way?: This is the previous code I

In Microsoft Visual Studio 2015 and using C# programming, how do you code the following in the easiest way?:In Microsoft Visual Studio 2015 and using C# programming, how do youThis is the previous code I have:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace ScoreCalculator { public partial class frmScoreCalculator : Form { //Declare two class variables to store score total and the score count decimal scoreTotal = 0; decimal scoreCount = 0; public frmScoreCalculator() { InitializeComponent(); } ///

/// This is an event handler that adds the scores together /// when the user clicks the add button /// /// /// private void btnAdd_Click(object sender, EventArgs e) { //Get the score entered by the user decimal score = Convert.ToDecimal(txtScore.Text);

//Add score to total score scoreTotal = scoreTotal + score;

//Increment score count by 1 scoreCount++;

//Calculate the average score decimal avgScore = scoreTotal / scoreCount;

//Show the results txtScoreTotal.Text = scoreTotal.ToString(".##"); txtScoreCount.Text = scoreCount.ToString(".##"); txtAverage.Text = avgScore.ToString(".##");

//Set the focus to the score textbox txtScore.Focus(); txtScore.SelectAll();

} ///

/// This is an event handler that clears all of the text /// boxes when the user clicks the ClearScores button /// /// /// private void btnClearScores_Click(object sender, EventArgs e) { //Clear all of the text boxes txtScore.Text = ""; txtScoreTotal.Text = ""; txtScoreCount.Text = ""; txtAverage.Text = "";

//Set the class variables to their beginning value scoreCount = 0; scoreTotal = 0;

//Set focus to the score textbox txtScore.Focus(); } ///

/// This is an event handler that closes the form when the user /// clicks the button /// /// /// private void btnExit_Click(object sender, EventArgs e) { //Close the form when the user clicks the button this.Close(); } } }

In this exercise, you'll enhance the Score Calculator form you built in Homework 2, Problem #3 so it saves the scores the user enters in an array and then lets the user display the sorted scores in a dialog box. Score Calculator Sorted Scores Score: 9 Add Score total: 472 Score count: 5 Average: 94 Display Scores 89 92 96 97 98 Clear Scores Edt OK I. Copy the ScoreCalculator folder containing the program you built for Homework 2, Problem #3. Name the new folder ScoreCalculatorWithArray. Open the program 2. Delete the class-level score total variable and replace it with a class-level array that can hold up to 20 scores. 3. Modify the Click event handler for the Add button so it adds the score that's entered by the user to the next element in the array. To do that, you can use the class-level score count variable to refer to the element 4. Move the Clear Scores button as shown above. Then, modify the Click event handler for this button so it removes any scores that have been added to the array. The easiest way to do that is to create a new array and assign it to the array variable (e.g., scores-new int[20];) 5. Add a Display Scores button that sorts the scores in the array, displays the scores in a dialog box, and moves the focus to the Score text box. Be sure that only the elements that contain scores are displayed In this exercise, you'll enhance the Score Calculator form you built in Homework 2, Problem #3 so it saves the scores the user enters in an array and then lets the user display the sorted scores in a dialog box. Score Calculator Sorted Scores Score: 9 Add Score total: 472 Score count: 5 Average: 94 Display Scores 89 92 96 97 98 Clear Scores Edt OK I. Copy the ScoreCalculator folder containing the program you built for Homework 2, Problem #3. Name the new folder ScoreCalculatorWithArray. Open the program 2. Delete the class-level score total variable and replace it with a class-level array that can hold up to 20 scores. 3. Modify the Click event handler for the Add button so it adds the score that's entered by the user to the next element in the array. To do that, you can use the class-level score count variable to refer to the element 4. Move the Clear Scores button as shown above. Then, modify the Click event handler for this button so it removes any scores that have been added to the array. The easiest way to do that is to create a new array and assign it to the array variable (e.g., scores-new int[20];) 5. Add a Display Scores button that sorts the scores in the array, displays the scores in a dialog box, and moves the focus to the Score text box. Be sure that only the elements that contain scores are displayed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!