473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to get the the average of my 5 grades

Expand|Select|Wrap|Line Numbers
  1. function ave()
  2. {
  3. var num1=prompt("enter your first grade");
  4. document.write("<br>ENG121:"+num1);
  5. var num2=prompt("enter your second grade");
  6. document.write("<br>ACC101:"+num2);
  7. var num3=prompt("enter your third grade");
  8. document.write("<br>CS201:"+num3);
  9. var num4=prompt("enter your fourth grade");
  10. document.write("<br>LIT111:"+num4);
  11. var num5=prompt("enter your fifth grade");
  12. document.write("<br>CS211:"+num5);
  13. var total=prompt("total average");
  14.  
  15. var total= parseInT(num1) +parseInT(num2) +parseInT(num3) +parseInT(num4) +parseInT(num5) /parseInt(5);
  16. document.write("<br>THE TOTAL AVE IS:"+total);
  17.  
  18.  
Sep 19 '12 #1
2 2821
Rabbit
12,516 Expert Mod 8TB
You need to add up all the values before . Right now you are only dividing the last number.
Sep 19 '12 #2
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. var total= (parseInt(num1) +parseInt(num2) +parseInt(num3) +parseInt(num4) +parseInt(num5)) /parseInt(5);
  2.  
since you need to divide the total by 5 you should wrap your adding phrase in () so it does all of those adds first before executing the division. Also in a lot of them you had parseInT which would be causing a syntax error and not doing any of the math at all.
Sep 22 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tony Lennard | last post by:
I have several queries, which generate about 10 fields each a text field of length 2 (which contain effort and attainment grades), eg A2, B4, A3, A3. I am trying to calculate an 11th fields, which...
11
by: Penfold | last post by:
I'd appreciate help converting student average test scores into grades. My problem is that I need to allocate one of about 20 grades (3a,3b,3c,4a,4b,4c etc through to 8c plus a couple of others)....
3
by: spike29 | last post by:
write an application in Javascriopt that will process peoplesgrades Each person has 4 test grades and you are to compute the average for each sudent. The input will include: 1. student name -...
2
by: tatum | last post by:
I really just need some pointers... jumping points from here... something the problem: Write a grading program for a class with the following grading policies: 1. There are two quizzes,...
2
by: gdarian216 | last post by:
the program reads input from a file and then outputs the averages and grade. for some reason it is reading in the same line twice and it doesn't print out the grade. everything else is correct, if...
3
by: Salad | last post by:
http://www.mathwords.com/w/weighted_average.htm At the above link gives an example of a weighted average. It uses the following example: Grades are often computed using a weighted average....
3
by: hanie | last post by:
a student wants to know his grade average for the semester. the grades are give in letter grades with numeric equivalents. develop a solution to calculate a grade average given the letter grades(the...
2
by: jac130 | last post by:
I have an array, populated with student grades. there is a list of student names, but their grades are stored in a class level array. there is a calculate average button,that is supposed to calculate...
4
by: Nick Richards | last post by:
Hi folks, Hoping you can help me out. At uni we have an alpha-numeric grading system, where A16 is a top pass and F1 is an abject fail. I need to average the grades for 2 semesters. I'm thinking...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.