473,761 Members | 9,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get the the average of my 5 grades

1 New Member
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 2830
Rabbit
12,516 Recognized Expert Moderator MVP
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 Recognized Expert Top Contributor
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
1793
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 is an average of the other fields (in this case A3). Does anyone have any ideas? Tony Lennard
11
3226
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). This comes up as too complex using nested IIf, then, else. I tried a lookup table but here the problem I found was that unless the average test score matches exactly then no grade is returned. For example a score of 11.0 returns grade 4b but a...
3
2488
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 - string type 2. test grade 1 - integer 3. test grade 2 - integer 4. test grade 3 - integer 5. test grade 4 - integer In your program, keep a count of the number of students read in. When finish entering grades for each student, compute the average...
2
5207
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, each graded on the basis of 10 points. 2. There is one midterm exam and one final exam, each graded on the basis of 100 points. 3. The final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a...
2
2201
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 someone can help me thanks this is my code.... #include <cstdlib> #include <iostream> #include <string> #include <vector>
3
5308
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. Suppose that homework counts 10%, quizzes 20%, and tests 70%. If Pat has a homework grade of 92, a quiz grade of 68, and a test grade of 81, then
3
4873
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 grade average is is figured per unit of credit!) A=4.0 B=3.0 C=2.0 D=1.0 F=0.0 use a trip value to stop the processing of the loop and case structure to find the grade points
2
5661
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 the grades in the array. But my button only returns the last grade that was entered, not the average, here is my code: public Class btnAdd Dim grades() As Double Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As...
4
2567
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 that I need to remove the letter take the average and then put on a new calculated letter (eg. A16 + F2 gives an average of C9)but don't know where to begin. Any hints would be very much appreciated. Cheers muchly Nick
0
10136
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9923
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9811
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8813
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7358
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6640
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.