Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have an assignment to make a score calculator in C# The assignment description is: This application will take scores input by a user and

I have an assignment to make a score calculator in C#

The assignment description is: This application will take scores input by a user and store the scores into an array. Declare a class variable for an array that can hold up to 20 scores. The add button will add scores to the array. The remainder of the text boxes will also be manipulated each time you click the add button. The scores should update based on every additional entry to the array. If the user tries to enter 21 entries the user should be alerted that they cannot enter any more entries. The display score button displays the scores in a message box which are sorted from smallest to largest, and moves the focus to the Score text box. Be sure that only the elements that contain scores are displayed. The clear scores button will empty the array Exit will close the application

The form and output should look like This: image text in transcribed

I have this code so far and it is not displaying, not sure what is happening with it that it is not displaying, can't seem to locate the error.

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 Lab6_Part1_ScoreCalculator_CRupe { public partial class FrmScoreCalculator : Form { int[] scoresArray = new int[20]; int total = 0; int count = 0; int i = 0; public FrmScoreCalculator() { InitializeComponent(); } private void BtnAdd_Click(object sender, EventArgs e) { try { if (IsValidData()) { int score = Convert.ToInt32(TxtScore.Text); scoresArray[count] = score; // total total = total + scoresArray[i]; count += 1; // counter // average int average = total / count; // displaying the text TxtScoreTotal.Text = total.ToString(); TxtScoreCount.Text = count.ToString(); TxtScoreAverage.Text = average.ToString(); i++; TxtScore.Focus();

}

} catch (Exception ex) { MessageBox.Show("Invalid input"); } } public bool IsValidData() { return // Validate the Score text box IsPresent(TxtScore, "Score") && IsInt32(TxtScore, "Score") && IsWithinRange(TxtScore, "Score", 01, 100); } public bool IsPresent(TextBox textBox, string name) { if (textBox.Text == "") { MessageBox.Show("score is a required field"); return false; } else return true; } public bool IsInt32(TextBox textBox, string name) { int value; if (int.TryParse(textBox.Text, out value)) {

return true; } else { MessageBox.Show("Input a valid integer"); return false; }

} public bool IsWithinRange(TextBox textBox, string name, decimal min, decimal max) { if (Convert.ToInt32(textBox.Text) > max || Convert.ToInt32(textBox.Text)

} // display score private void BtnDisplay_Click(object sender, EventArgs e) { List array = new List(); for (int i = 0; i x.ToString()).ToArray()); MessageBox.Show(toDisplay); } // clear list private void BtnClear_Click(object sender, EventArgs e) { total = 0; count = 0; i = 0; TxtScore.Text = ""; TxtScoreTotal.Text = ""; TxtScoreCount.Text = ""; TxtScoreAverage.Text = ""; for (int j = 0; j Score Calculator Sorted Scores Score: 981 Add Score total: 472 Score count: 5 Average: 94 89 92 96 97 98 Display Scores Clear Scores Edt OK

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Define confusion matrix.

Answered: 1 week ago

Question

Question How are IRAs treated for state tax law purposes?

Answered: 1 week ago