Hi

I'm tackling down an extra credit assignment which I'm so confused on.
We are to design a basic JS Grade Calc where we input our scores and it gives us our grade.

For extra credit we have to snazz it up a bit.

So far this is what I want it to look like:

I would like for it to add up all the CP scores and give the amount for that, then do the same for the lab scores, and then the tests/final exam.

In the box below the Calculate Grade, I would like it to give this kind of answer:

Here are your scores thank you for waiting:

CP: <score>
Labs: <score>
Exams: <score>
Total Score: <score>

Congratulations!~ CIS 101 is now over. :)

Any and all help creating the formula part of this would be great!

## All 4 Replies

This is my script:

``````<center><h1><i> Grade Calculator </i></h1></center>
<!-- Start script -->
<script type="text/javascript">

// Output Variable

// Input Variables

// Inputed Variables to the output variable
gradeOut = "Congratulations!~ CIS 101 is now over :) \n\n";

// Formula

// Grade letter to Output Variable

// Results in the text area

}
</script>
<body>

<!-- Start the form -->
<!-- Input all the grades -->
<table width="100%" height="100%" cellpadding="3" cellspacing="5" border="1px">
<tr><td align="center" valign="top">
<h3> Class Participation </h3>
CP 9/5:<br>
<input type="text" name="CP1" size="10"><br><br>

CP 10/3:<br>
<input type="text" name="CP2" size="10"><br><br>

CP 10/17:<br>
<input type="text" name="CP3" size="10"><br><br>

CP 10/31:<br>
<input type="text" name="CP4" size="10"><br><br>

CP 11/7:<br>
<input type="text" name="CP5" size="10"><br><br>

CP 11/21:<br>
<input type="text" name="CP6" size="10"><br><br>

CP 12/5:<br>
<input type="text" name="CP7" size="10"><br><br></td>

<td align="center" valign="top">

Lab #1:<br>
<input type="text" name="labs1" size="10"><br><br>

Lab #2:<br>
<input type="text" name="labs2" size="10"><br><br>

Lab #3:<br>
<input type="text" name="labs3" size="10"><br><br>

Lab #4:<br>
<input type="text" name="labs4" size="10"><br><br>

Lab #5:<br>
<input type="text" name="labs5" size="10"><br><br>

Lab #6:<br>
<input type="text" name="labs6" size="10"><br><br></td>
<td align="center" valign="top">

Test #1:<br>
<input type="text" name="Tests1" size="10"><br><br>

Test #2:<br>
<input type="text" name="Tests2" size="10"><br><br>

Final Exam:<br>
<input type="text" name="final" size="10"><br><br>

<br><h3> Extra Credit</h3>

EC:<br>
<input type="text" name="ec" size="10"><br><br>
</td></tr>
</table><br><br>
<center>
<br>
<br>

<!-- Textarea used to return grades -->
<br>
</p>
</center>
</form>``````

The problems I'm having are here:

``````// Inputed Variables to the output variable
gradeOut = "Congratulations!~ CIS 101 is now over :) \n\n";

// Formula

The formula itself so it outputs the correct answer.
And of course, how to get it to add up all the cps and give me a number, and the same for the rest.

Your HTML document is not valid; it lacks a DOCTYPE. Also your question isn't very clear here. What kind of an help do you need since except for a few problems it pretty much looks OK. As for the formula, you would be the best person to come up with it. Here is a cleaner valid version of the same code. Just plug-in your formula calculation part and it should go well.

``````<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Vim">
<meta name="author" content="sos">
<script type="text/javascript">
}

var totalGrade = 56 /* some formula */;

var cp = 'some cp', lab = 'some-lab',
exams = 'some-exams', credit = 'some-credit'

gradeOut += "Congratulations!~ CIS 101 is now over :) \n\n";

}
</script>
<body>
<div>
<tr><td align="center" valign="top">
<h3> Class Participation </h3>
cp 9/5:<br>
<input type="text" name="cp1" size="10"><br><br>

cp 10/3:<br>
<input type="text" name="cp2" size="10"><br><br>

cp 10/17:<br>
<input type="text" name="cp3" size="10"><br><br>

cp 10/31:<br>
<input type="text" name="cp4" size="10"><br><br>

cp 11/7:<br>
<input type="text" name="cp5" size="10"><br><br>

cp 11/21:<br>
<input type="text" name="cp6" size="10"><br><br>

cp 12/5:<br>
<input type="text" name="cp7" size="10"><br><br></td>

<td align="center" valign="top">

Lab #1:<br>
<input type="text" name="labs1" size="10"><br><br>

Lab #2:<br>
<input type="text" name="labs2" size="10"><br><br>

Lab #3:<br>
<input type="text" name="labs3" size="10"><br><br>

Lab #4:<br>
<input type="text" name="labs4" size="10"><br><br>

Lab #5:<br>
<input type="text" name="labs5" size="10"><br><br>

Lab #6:<br>
<input type="text" name="labs6" size="10"><br><br></td>
<td align="center" valign="top">

Test #1:<br>
<input type="text" name="tests1" size="10"><br><br>

Test #2:<br>
<input type="text" name="tests2" size="10"><br><br>

Final Exam:<br>
<input type="text" name="final" size="10"><br><br>

<br><h3> Extra Credit</h3>

EC:<br>
<input type="text" name="ec" size="10"><br><br>
</td></tr>
</table>
<br>
<br>
<br>
<br>
</div>
</form>
</body>
</html>``````

Umm pretty much the formula is what Im having trouble with...
and coming up with the proper part to give me the results. Our teacher gave us this:

Pretty much he wants us to make it like that with the added inputs.

and...lol I'm so confused with it

Now the part I don't understand from the calculator we are supposed to go off of is this:

``````// Add the inputed Grades to the output variable

// Calculate the course grade via the formula

// Check for what grade letter and add to output variable (extra credit)

In the part that says: "// Add the inputed Grades to the output variable" I need it to add up all my CPs and give me a total for that, as well as the labs, and the exams.

So in essence I need it to look like this:
CP: <all cp scores added up>
Labs: <all lab scores added up>
Exams: <all exam scores added up>
Total Score: <score>