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?:
This 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(); } ///
//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();
} ///
//Set the class variables to their beginning value scoreCount = 0; scoreTotal = 0;
//Set focus to the score textbox txtScore.Focus(); } ///
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
Get step-by-step solutions from verified subject matter experts
