Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm stuck on how to implement an int list and set my validations to check for integers. Thank you for all the help you can

I'm stuck on how to implement an int list and set my validations to check for integers. Thank you for all the help you can assist me with.

In this exercise, youll modify the Score Calculator form of extra exercise A6-E1 so the scores are stored in a list instead of an array.

image text in transcribed

1. Your exercise name is Assignment6 \Ex2_ScoreCalculator.

2. Replace the declaration for the array variable with a declaration for a List object,

and delete the class variable for the score count.

3. Modify the Click event handler for the Add button so it adds the score thats entered by the user to the list.

In addition, delete the statement that increments the score count variable you deleted.

Then, declare a local variable to store the count, and assign the Count property of the list to this variable.

4. Modify the Click event handler for the Clear Scores button so it removes any scores that have been added to the list.

5. 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.

6. Test the application to be sure it works correctly.

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 Form1 : Form { public Form1() { InitializeComponent(); }

int total = 0; int count = 0; //something will be here

private void btnExit_Click(object sender, EventArgs e) { this.Close(); }

private void btnAdd_Click(object sender, EventArgs e) { try { if (IsValidData()) { int score = Convert.ToInt32(txtScore.Text); total += score; count += 1; int average = total / count; txtScoreTotal.Text = total.ToString(); txtScoreCount.Text = count.ToString(); txtAverage.Text = average.ToString(); txtScore.Focus(); } } catch (Exception ex) { //implement me //stack, type, message } }

//implement me private void btnDisplay_Click(object sender, EventArgs e) {

}

private void btnClear_Click(object sender, EventArgs e) { total = 0; txtScore.Text = ""; txtScoreTotal.Text = ""; txtScoreCount.Text = ""; txtAverage.Text = ""; txtScore.Focus(); }

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) { //implement me //test and error message return true; }

public bool IsInt32(TextBox textBox, string name) { //implement me //test and error message return true; }

public bool IsWithinRange(TextBox textBox, string name, decimal min, decimal max) { //implement me //test and error message return true; }

} }

Score Calculator l el te Score: 98 Add Score total 472 Score count 5 Average: 94 aear scores Display Scores Sorted Scores 89 92 97 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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago