Stats: 3,249,110 members, 8,140,002 topics. Date: Sunday, 20 April 2025 at 06:21 PM |
Nairaland Forum / Science/Technology / Programming / Javascript Source Code For GPA Calculator (2417 Views)
Review: I Developed A GPA Calculator For Student / Free PHP, Node js ,Mongo db, Angular And C# Proje Source Code With Documentation / My Semester GPA Calculator With Javascript (2) (3) (4)
Javascript Source Code For GPA Calculator by dondavad: 12:55am On Dec 24, 2017 |
I have a lill problem in JavaScript... I saw this source code for a GPA calculator... but it's not working properly, need help fixing it <CENTER> <FORM Name="GPACalcForm"> <TABLE BORDER=5 BGCOLOR= #C0C0C0 CELLPADDING="5" CELLSPACING="2"> <TH></TH> <TH>Grade</TH> <TH>Credits</TH> <TR> <TD>Class 1</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR1" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR1" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 2</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR2" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR2" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 3</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR3" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR3" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 4</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR4" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR4" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 5</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR5" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR5" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 6</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR6" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR6" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 7</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR7" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR7" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR> <TD>Class 8</TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="GR8" ALIGN=TOP MAXLENGTH=5></TD> <TD><INPUT TYPE=TEXT SIZE=5 NAME="CR8" ALIGN=TOP MAXLENGTH=5></TD> </TR> <TR ALIGN=CENTER> <TD COLSPAN=3><INPUT TYPE="BUTTON" VALUE="Calculate" NAME="CalcButton" OnClick="gpacalc()"></TD> </TR> </TABLE> </FORM> <BR> <P> <P> </CENTER> <BR> <SCRIPT LANGUAGE="JavaScript"> <!-- function gpacalc() { //define valid grades and their values var gr = new Array(9); var cr = new Array(9); var ingr = new Array(5); var incr = new Array(5); // define valid grades and their values var grcount = 11; gr[0] = "A+"; cr[0] = 5; gr[1] = "A"; cr[1] = 4; gr[2] = "A-"; cr[2] = 3.66; gr[3] = "B+"; cr[3] = 3.33; gr[4] = "B"; cr[4] = 3; gr[5] = "B-"; cr[5] = 2.66; gr[6] = "C+"; cr[6] = 2.33; gr[7] = "C"; cr[7] = 2; gr[8] = "C-"; cr[8] = 1.66; gr[9] = " ![]() cr[9] = 1; gr[10] = "F"; cr[10] = 0; // retrieve user input ingr[0] = document.GPACalcForm.GR1.value; ingr[1] = document.GPACalcForm.GR2.value; ingr[2] = document.GPACalcForm.GR3.value; ingr[3] = document.GPACalcForm.GR4.value; ingr[4] = document.GPACalcForm.GR5.value; ingr[5] = document.GPACalcForm.GR6.value; ingr[6] = document.GPACalcForm.GR7.value; ingr[7] = document.GPACalcForm.GR8.value; incr[0] = document.GPACalcForm.CR1.value; incr[1] = document.GPACalcForm.CR2.value; incr[2] = document.GPACalcForm.CR3.value; incr[3] = document.GPACalcForm.CR4.value; incr[4] = document.GPACalcForm.CR5.value; incr[5] = document.GPACalcForm.CR6.value; ingr[6] = document.GPACalcForm.GR7.value; ingr[7] = document.GPACalcForm.GR8.value; // Calculate GPA var allgr =0; var allcr = 0; var gpa = 0; for (var x = 0; x < 5 + 3; x++) { if (ingr[x] == "" ![]() // if (isNaN(parseInt(incr[x]))) alert("Error- You did not enter a numeric credits value for Class If the class is worth 0 credits then enter the number 0 in the field." ![]() var validgrcheck = 0; for (var x = 0; x < grcount; x++) { if (ingr[x] == gr[x]) { allgr = allgr + (parseInt(incr[x],10) * cr[x]); allcr = allcr + parseInt(incr[x],10); validgrcheck = 1; break; } } if (validgrcheck == 0) { alert("Error- Could not recognize the grade entered for Class " + eval(x + 1) + ". Please use standard college grades in the form of A A- B+ ...F." ![]() return 0; } } // this if-check prevents a divide by zero error if (allcr == 0) { alert("Error- You did not enter any credit values! GPA = N/A" ![]() return 0; } gpa = allgr / allcr; alert("GPA = " + eval(gpa)); return 0; } //--> </SCRIPT> |
Re: Javascript Source Code For GPA Calculator by Teedawg: 3:43am On Dec 24, 2017 |
A source code that is not yours and doesn't have proper commenting how will you understand it lol |
Re: Javascript Source Code For GPA Calculator by fizyalasdair(m): 7:03am On Dec 24, 2017 |
To be able to modify a source code, you'll have to understand the language in its entirety. Modifying usually is a short cut and will not improve your skills. Anyways I hope someone good in Javascript can help you |
Re: Javascript Source Code For GPA Calculator by asalimpo(m): 8:43am On Dec 24, 2017 |
try to solve the problem yourself. sweat. If it's an assignment work your way through it first, dont look for easy way out. ps. I think you are lazy and just want to sponge off other people. Use ur brain. 1 Like |
Re: Javascript Source Code For GPA Calculator by dondavad: 9:19am On Dec 25, 2017 |
asalimpo:Lol..... well you are damn right, am very lazy. are you a programmer? |
Re: Javascript Source Code For GPA Calculator by Darey00(m): 6:39pm On Dec 26, 2017 |
Mehn see code.... my eyes are hurting |
Re: Javascript Source Code For GPA Calculator by agwaisrael(m): 6:20am On Dec 27, 2017 |
At what point in all this do you have errors? Does your function get called at all? Try using chrome, open developer console and read the errors there. Also print to the console so that you know where in your code lies the error. I'm unable to help, cos you didn't state point of failure or any useful information |
(1) (Reply)
Chat GPT Can Lie Oo!! Here What It Says About Peter Obi!!?? / Laptop & Desktop Prices In Nigeria (for Programmers) / Php Form To Mail Problem
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2025 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24 |