150 likes | 162 Views
Test-driving the Class Average Application for grade entry, average calculation, and focus control. Easily add, display, and clear grades as needed. Use do...while statement for accurate averages.
E N D
Test-Driving the Class Average Application Entering grades in the Class Average application. • Entering quiz grades • Enter a grade into the Enter grade:TextBox • Click Add Grade Button • Grade added to ListBox • Focus given to TextBox
Label displaying average Click to calculate class average Test-Driving the Class Average Application Displaying the class average. • Calculating the average • Click the AverageButton • Average displayed in output Label • Add GradeButton enabled
Test-Driving the Class Average Application Entering a new set of grades. • Entering another set of grades • Old quiz grades removed from ListBox • New grade added to ListBox
do…while Repetition Statement • do…while example: • int intCounter = 1;do{ lstDisplay.Items.Add( intCounter ) intCounter++;} while ( intCounter <= 2 ); • Set counter to 1 • Execute body of do…while statement while the counter is less than or equal to 2
Creating the Class Average Application ClassAverage application’s Form in design view. • Template application • Contains: • ListBox • Buttons • Output Label
Clearing the grade list and class average Creating the Class Average Application Clearing the ListBox and output Label after a calculation. • Clearing ListBox and output Label • If output Label contains text • Clear output Label of previous result • Clear ListBox of previous quiz grades
Adding a numeric grade to the ListBox and clearing the user input from the TextBox Creating the Class Average Application Adding the grade input to the ListBox and clearing the Enter grade: textBox. • Displaying grades • Add grade to ListBox • Clear TextBoxtxtInput
Transferring the focus of the application to theTextBox Creating the Class Average Application Transferring the focus to the TextBox control. • Transferring focus to a control • Makes application easier to use • Use method Focus of that control
Disabling theAddGradeButtonand transferring the focus to the AverageButton Using the Focus method ClassAverage.cs(4 of 6)
Using a do…while statement to calculate the class average Enabling theAddGradeButtonand transferring the focus to the Enter grade:TextBox ClassAverage.cs(5 of 6)