vb.net - This is an assignment I have to turn in. I am missing something about the function calculation -
vb.net - This is an assignment I have to turn in. I am missing something about the function calculation -
i have 3 test scores lowest score dropped. function used calculate final grade , grade has converted number letter. have done can trying figure out , create sure function written correctly.
'i set these @ public class used throughout programme dim test1 double dim test2 double dim test3 double dim pupil string dim result1 string dim total string function semestergrade(byval t1 double, byval t2 double, byval t3 double) double 'this function determines test scores , drops lowest score calculation if t1 < t2 , t1 < t3 total = cstr(((t2 + t3) / 2)) elseif t2 < t3 , t2 < t1 total = cstr(((test1 + test3) / 2)) elseif t3 < t2 , t3 < t1 total = cstr(((t1 + t2) / 2)) 'i added if statement calculate if scores same because programme not give me right output elseif t1 = t2 , t2 = t3 total = cstr((t1 + t2 + t3) / 3) end if 'this returns result function homecoming cdbl(total) end function private sub btndetermine_click(byval sender system.object, byval e system.eventargs) handles btndetermine.click dim result string 'these pull info textboxes test1 = cdbl(txtfirst.text) test2 = cdbl(txtsecond.text) test3 = cdbl(txtthird.text) pupil = txtname.text.toupper 'this how utilize function calculation result = cstr((semestergrade(test1, test2, test3))) 'this convert number score letter if cdbl(total) >= 90 result1 = ("a") elseif cdbl(total) >= 80 result1 = "b" elseif cdbl(total) >= 70 result1 = "c" elseif cdbl(total) >= 60 result1 = "d" elseif cdbl(total) < 60 result1 = "f" end if 'this output result txtresult.text = pupil & ": " & result1 end sub end class
the problem calling function variable , comparing variable. replace below part , retry;
'this how utilize function calculation result = (semestergrade(test1, test2, test3)) 'this convert number score letter if result >= 90 result1 = ("a") elseifresult >= 80 result1 = "b" elseif result >= 70 result1 = "c" elseif result >= 60 result1 = "d" elseif result < 60 result1 = "f" end if
vb.net visual-studio-2010
Comments
Post a Comment