Question: C# i have this code and it works but it is directly on a windows from button i need to: 1. create a class called
C#
i have this code and it works but it is directly on a windows from button i need to:
1. create a class called myCalcClass
2.create a function called fCalcGrade
3.in my btnGrade_Click create the object from myCalcClass
4.call the function fCalcGrade
5. return the value to display in lblGraderesults.Text
this is the code that needs to go into the fCalcGrade passing along the variables needed
private void btnCalculate_Click(object sender, EventArgs e) { int grade = Convert.ToInt32(txtGrade.Text); if(grade <60){ lblGradeResults.Text = "Your Grade is F"; } if (grade >= 60) {
lblGradeResults.Text = "Your Grade is D"; } if(grade >= 70) { lblGradeResults.Text = "Your Grade is C"; } if (grade >= 80) { lblGradeResults.Text = "Your Grade is B"; } if (grade >=90) { lblGradeResults.Text = "Your Grade is A "; }
if (grade == 100) { lblGradeResults.Text = "Your Grade is A+++"; } if (grade > 100) { MessageBox.Show("type a number lower than or equal to 100"); }
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
