Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5) For task ‘e’, move the code that creates and posts the student grade report f

ID: 3632451 • Letter: 5

Question

5) For task ‘e’, move the code that creates and posts the student grade report from the event handler to its own method.
RESTICTIONS:
i) This method will have at least five parameters; the student’s name, the course name, the grade value, the letter grade, and the Label object who’s Text property will be updated with the grade report.
ii) This is a void method
Need to change the code below and make a new method and call.
public partial class Form1 : Form
{
const int BONUS_POINTS = 10;
const int PASS_FAIL_LEVEL = 70;
const double ASSIGNMENT_WEIGHT = 0.50;
const double TEST_WEIGHT = 0.50;
const string PASS_FAIL_COURSE = "INFO1200";
const string EASY_COURSE = "INFO0123";

private void btnCalc_Click(object sender, EventArgs e)
{
bool goodInput = true;
double grade = 0;
string letterGrade;
int aGrade = 0, mGrade = 0, fGrade = 0;
bool loveChecked;



//Calculte the grade according to the course's grading scheme.

switch (tbCourse.Text)
{
case PASS_FAIL_COURSE:
if ((aGrade > PASS_FAIL_LEVEL)
&& ((mGrade > PASS_FAIL_LEVEL) || (fGrade > PASS_FAIL_LEVEL)))
{
grade = 100;
}
else
{
grade = 0;
}

break;

case EASY_COURSE:
if (aGrade > grade)
{
grade = aGrade;
}

if (mGrade > grade)
{
grade = mGrade;
}

if (fGrade > grade)
{
grade = fGrade;
}

break;

default:
grade = aGrade * ASSIGNMENT_WEIGHT;

grade += (mGrade + fGrade) / 2 * TEST_WEIGHT;

break;
}
/*
* Convert grade to a letter grade
*/

if (grade >= 90)
{
letterGrade = "A";
}
else
if (grade >= 80)
{
letterGrade = "B";
}
else
if (grade >= 70)
{
letterGrade = "C";
}
else
if (grade >= 60)
{
letterGrade = "D";
}
else
{
letterGrade = "E";
}
/*
* Post the grade report
*/
lblGrade.Text = tbName.Text + " in course " + tbCourse.Text
+ " has a grade of " + grade.ToString("N3")
+ "% (" + letterGrade + ")";
}
}

Explanation / Answer

Here's the method to post the grade to the desired label:


You'd call it from your original code like this:


Hope this helps -- let me know if you have any questions.

Joe

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote