PDA

View Full Version : ASP Caculation help


fishbone34
09-27-2004, 11:14 PM
Hello, I Have a caculation within a script that outputs a Number between 10 to 100 based on table data. Here is the caculation code:

HERE it is:
'Calculate Total Score
faceSubScore = (CInt(tablearray(7,0)) + CInt(tablearray(9,0)) + CInt(tablearray(11,0)) + CInt(tablearray(13,0)) + CInt(tablearray(15,0)) + CInt(tablearray(17,0)) + CInt(tablearray(19,0)) + CInt(tablearray(21,0)))

'response.write("faceSubScore: " &faceSubScore&"<br>")

CommSubScore = (CInt(tablearray(23,0))+CInt(tablearray(25,0))+CInt(tablearray(27,0))+CInt(tablearray(29,0))+CInt(ta blearray(31,0)))

'response.write("CommSubScore: " &CommSubScore&"<br>")

totalScore = (faceSubScore)+(CommSubScore)

totalScore = round(totalScore,2)

'response.write("Total Score: "&totalScore&"<br>")

The Code above spits out the Total Score anywhere from 10 to 100. I would like to write something that would output the Totalscore, based on a scale, to numbers between 1 - 5.

Example: the total score = 92

The Scale:
100 = 5
90 - 99 = 4
80 - 89 = 3
70 -79 = 2
69 or LESS = 1

The Total Score will be = 4


Is this Possible?


Chris
chris@thesouthside.net

Roy Sinclair
09-27-2004, 11:28 PM
dim temp
temp = Int(totalscore / 10)
if temp < 6 then
totalscore = 1
else
totalscore = temp - 5
end if


This should work but I haven't tested it.

fishbone34
09-28-2004, 03:47 PM
Thanks Roy, I had to modify it but you sent me in the right direction.

THE CODE I USED:
'Calculate Total Score
faceSubScore = (CInt(tablearray(7,0)) + CInt(tablearray(9,0)) + CInt(tablearray(11,0)) + CInt(tablearray(13,0)) + CInt(tablearray(15,0)) + CInt(tablearray(17,0)) + CInt(tablearray(19,0)) + CInt(tablearray(21,0)))
'response.write("faceSubScore: " &faceSubScore&"<br>")
CommSubScore = (CInt(tablearray(23,0))+CInt(tablearray(25,0))+CInt(tablearray(27,0))+CInt(tablearray(29,0))+CInt(ta blearray(31,0)))
'response.write("CommSubScore: " &CommSubScore&"<br>")
totalScore = (faceSubScore)+(CommSubScore)
totalScore = round(totalScore,2)
'response.write("totalScore "&totalScore&"<br>")
temp2 = (Int(totalscore / 10))
if temp2 < 6 then
totalscore2 = 1
else
totalscore2 = temp2 - 5
end if
'response.write("Total Score: "&totalScore2&"<br>")


Thanks!