Forum Moderators: open

Message Too Old, No Replies

Averaging Calculator

need help with creating calculator

         

Negami

3:24 pm on Jul 24, 2007 (gmt 0)

10+ Year Member



Here's my situation:
I created a test that, when taken, will show you your results at the end. Within the test are chapters [for example] A [section 1], A [section 2], A [section 3], B, and C. The lowest possible score is 75%
If a student passes chapter A [sections 2-3], B, and C, but did NOT pass chapter A [section 1], it will say they passed chapters B and C. The only way they can pass chapter A is if they pass ALL the sections.

Here's what I'm wanting to do:
I'm wanting to create a calculator inside the program I'm using that will take the scores from A [sections 1-3] and average them out so I can take the variable and let them see that they passed chapter A. Can I get some help with this? I am VERY new to Javascript/AJAX/PHP coding but I can understand the terms/concepts of it.

Is there a way to do this?

Xapti

4:40 pm on Jul 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't see if a person passed all 3 just by looking at their average.
I assume when you say 75% is the lowest possible score, you mean it is the passing score, right?

Take the following example: 74% test1, 74% test2, 100% test3. The average will be a randomish number above 75%, even though they failed the first two.

You have to examine each section of part A and perform logical ANDs on them.

For instance: if (a1>=.75 && a2>=.75 && a3>=.75){
a_pass=1;}
While the others would just be
if (b>=.75}{}
if (c>=.75}{}

if for whatever reason I misunderstood you, and you still need to find the average, just take the sum of the variables, and divide it by the number of variables.

[edited by: Xapti at 4:41 pm (utc) on July 24, 2007]

Negami

6:00 pm on Jul 24, 2007 (gmt 0)

10+ Year Member



I already have the program tell the person what their scores were, but it also says "you pass chapter A,B, or C" depending on which one they passed. However, since chapter A has 3 sections, it won't let me average their scores. So your 74%, 74%, and 100% would show as "fail."
What code would I use to do the averages of their scores? The scores are variables, so it makes coding easier but I don't know how to code a calculator. The program I'm using is Lectora, where it does the programming for mostly everything, but it won't do averages [and it lets me put in coding such as javascript, asp, jsp, css, etc].

Does this make sense?
______________________________________________________
You can't see if a person passed all 3 just by looking at their average.
I assume when you say 75% is the lowest possible score, you mean it is the passing score, right?
Take the following example: 74% test1, 74% test2, 100% test3. The average will be a randomish number above 75%, even though they failed the first two.

You have to examine each section of part A and perform logical ANDs on them.

For instance: if (a1>=.75 && a2>=.75 && a3>=.75){
a_pass=1;}
While the others would just be
if (b>=.75}{}
if (c>=.75}{}

if for whatever reason I misunderstood you, and you still need to find the average, just take the sum of the variables, and divide it by the number of variables.

Xapti

8:42 pm on Jul 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's basic math you learn on like grade 5-10 (I guess depending on the school system)...
as I mentioned "if for whatever reason I misunderstood you, and you still need to find the average, just take the sum of the variables, and divide it by the number of variables. ":

take your variables, a1, a2, a3, lets say, and add them: a1+a2+a3
then divide them by three (the number of variables), The final result looking like this:

average=(a1+a2+a3)/3

The average value will not be able to tell you whether or not they've passed or failed any of their tests though.

Negami

9:05 pm on Jul 26, 2007 (gmt 0)

10+ Year Member



I understand basic math, it's coding math that I don't understand. I've tried the code below [and I believe it is AJAX]:

Int TotalOne=A1
Int TotalTwo=A2
Int TotalThree=A3
TotalOne+TotalTwo+TotalThree=CombinedTotal
CombinedTotal/3

And that still doesn't change the average percentage of what the person scored. I just need a way to change "CombinedTotal" into a number that will show up as a percent. Then my program will show that they passed.
Make sense? I get the feeling you're misunderstanding me.

*Edit* My mistake. The code is C# I believe.

___________________________________________________________
It's basic math you learn on like grade 5-10 (I guess depending on the school system)...
as I mentioned "if for whatever reason I misunderstood you, and you still need to find the average, just take the sum of the variables, and divide it by the number of variables. ":
take your variables, a1, a2, a3, lets say, and add them: a1+a2+a3
then divide them by three (the number of variables), The final result looking like this:

average=(a1+a2+a3)/3

The average value will not be able to tell you whether or not they've passed or failed any of their tests though.

[edited by: Negami at 10:00 pm (utc) on July 26, 2007]

Negami

9:08 pm on Jul 26, 2007 (gmt 0)

10+ Year Member



The code you mentioned earlier, "if (a1>=.75 && a2>=.75 && a3>=.75){
a_pass=1;}" does something I can do already without coding. It's taking A1, A2, and A3 and averaging them, not saying "if you pass all these, then you passed the test."