-
April 24th, 2015, 12:06 PM
#1
Hi please help - problem with code that computes grades
Hi
I have a project to do for class that computes the total grade for the class based on grades and score weight.
I tried writing at lease half of the code by referring to the book but Im completely stuck and don't know what im doing.
I would really appreciate any help! I attached an image for the GUI and the partial code. Basically, when the user presses the enter hw grade button it prompts and input box that asks for all the hw grades. Same goes for the "enter quiz grades button" as well as "enter tests grade button". each list box has a different score weight: hw = 30% quizzes 10% tests 35%.
after all that, the user enters the final grade in the textbox which is 25% of the final grade. then when the user clicks "give me my A" it calculates the total grade based on the input.
HELP PLEEEEEEAse!!
thanks!
Public Class GradeCalculation
Private Sub GradeCalculation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub btnHomeWork_Click(sender As Object, e As EventArgs) Handles btnHomeWork.Click
'Declare Inital variables
Dim strHWGrade As String
Dim intHWGrade As Integer
Dim decResult As Decimal = 0D
Dim strInputMsgHW As String = "Please enter grade for homework week #"
Dim strNormalMsgHW As String = "Please enter grade for homework week #"
Dim strInputMsgQuizes As String = "Please enter grade for quiz number #"
Dim strInputMsgTests As String = "Please enter grade for test number #"
Dim strErrorMsg As String = "Error - Grade has to be between 1-100"
Dim strCancelClicked As String = ""
Dim intNumberOfEntries As Integer = 1
strHWGrade = InputBox(strInputMsgHW & intNumberOfEntries, " ")
'Declare and initial loop variables
Do Until strHWGrade = strCancelClicked
If IsNumeric(strHWGrade) Then
intHWGrade = Convert.ToDecimal(strHWGrade)
If intHWGrade > 0 And intHWGrade < 100 Then
lstHomeWork.Items.Add(intHWGrade)
intNumberOfEntries += 1
decResult += intHWGrade
strInputMsgHW = strNormalMsgHW
Else
strInputMsgHW = strErrorMsg
End If
End If
Loop
If intNumberOfEntries > 1 Then
lblResult.Visible = True
End If
End Sub
End Class
-
April 24th, 2015, 03:26 PM
#2
Re: Hi please help - problem with code that computes grades
You don't seem to have did much so far, just collecting a few numbers. That part seems to have an issue in that it would not accept a score of 100 but it probably should. You should probably change that to <101 rather than <100
So from your description you need something like that repeated 3 times for each type of score and you need to get an average from each of those and then use that to compute the final grade.
It would help if you asked a specific question. Tell us what part you are having trouble with or what you do not understand.
Always use [code][/code] tags when posting code.
-
April 24th, 2015, 06:16 PM
#3
Re: Hi please help - problem with code that computes grades
Originally Posted by DataMiser
You don't seem to have did much so far, just collecting a few numbers. That part seems to have an issue in that it would not accept a score of 100 but it probably should. You should probably change that to <101 rather than <100
So from your description you need something like that repeated 3 times for each type of score and you need to get an average from each of those and then use that to compute the final grade.
It would help if you asked a specific question. Tell us what part you are having trouble with or what you do not understand.
Ok, thank you for that information.
I realize I didnt do much, and I have stated that.
My specific questions:
1.I dont know what math calculation it will require, as each one of the list boxes has different precentage from the grade.
2.when i run the program, the input box asks me for the grade but doesnt do anything, for example it doesnt add it to the list box (eventhough i wrote that in the code)
-
April 24th, 2015, 10:30 PM
#4
Re: Hi please help - problem with code that computes grades
Actually you said you had written at least 1.2 the code but there is far less than 1/2 there.
You are prompting for input outside your loop so it will only ask for one value. If that value is 1-99 then it should be added to the listbox in the code that follows the if statement. Lblresult should become visible but has not been assigned a value so not sure what it would display if anything.
I would have to give some thought to how you would get your final grade but the first step would be to get the avg for each set. Once you have that then you would need to combine them, possibly by using the % that they should count toward the final grade. so 35% of the avg of the tests + 30% of the other group + 10% of the other and 25% of the final for a total score or something to that effect.
Edit: On second look I suppose that it could be just hanging in the loop causing the display to not be updated while adding the value you entered over and over and over again until you either stop the program or it crashes.
Last edited by DataMiser; April 24th, 2015 at 10:33 PM.
Always use [code][/code] tags when posting code.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|