array average across column

Ads

 
 

Share on Google+Share on Google+

Roy Patel
array average across column
0 Answer(s)      2 years and 11 months ago
Posted in : Java Beginners

How can I find the overall averages of the columns in this array? when i run my code it gives me an output that looks like this (showing me wrong averages):

How can I find the overall averages of the columns in this array? when i run my code it gives me an output that looks like this (showing me wrong averages):

0 1 2 3 overall grade Badger,Bradley 37 70 51 48 68.66666666666667 Emu,Emma 35 81 75 40 72.83333333333334 Aardvark,Alice 42 85 22 0 65.11111111111111 Dodo,Donald exc 12 25 0 54.17391304347826 Cassowary,Cassie 50 97 72 68 62.758620689655174

this is my code but i don't know what the mistake is

public static double[] computeAllGrades(int[][] scoreTable, int[] itemPointValues) {

            {
        double totalPoints = 0;
        double totalPointsPossible = 0;
        double allGrades[];
        double grade =0;

        allGrades= new double[scoreTable.length];
        int k = 0;

        for(int j = 0 ; j < scoreTable.length ; j++)
        {
                for(int i = 0 ; i < scoreTable[0].length ; i++)
                {
                        if(scoreTable[j][i] == -1)
                {
                        totalPoints = totalPoints + 0;
                        totalPointsPossible = totalPointsPossible + 0;

                }
                else
                {
                        totalPoints = totalPoints + scoreTable[j][i];
                totalPointsPossible = totalPointsPossible + itemPointValues[i];
                }
                                grade = (totalPoints/totalPointsPossible)*100;

                }

                allGrades[k] = grade;
                k++;
        }


        return allGrades;}}
Ads
View Answers
Ads









Related Tutorials/Questions & Answers:
array average across column
array average across column  How can I find the overall averages of the columns in this array? when i run my code it gives me an output that looks... of the columns in this array? when i run my code it gives me an output that looks
how to print the average of each column of 2d n*m array using java
how to print the average of each column of 2d n*m array using java  ... the content of file.now i want to calculate mean(average) of each column present...(String[] args) throws IOException { float column[] = new float[4
Advertisements
Average of Array
Average of Array       In this section, we will learn how to get an average of array. For this, first... that calculates the average of array (result/nums.length). And finally it will display
How to calculate average of array in Java?
How to calculate average of array in Java?  Hi, I have an integer array and I want to calculate the average of the values in it. How to calculate average of array in Java? Thanks   Hi, You can iterate through
Average
Average   I have created a file that reads in a text file for a combo box which are exams assignments and quizes. I then have a a textfield..., assignments, etc.) so I can have the average of each item. I then need to graph
Read text file to 2D array and sorting the second column
Read text file to 2D array and sorting the second column  we found.... when exams conducted fast 4 times.The first column is the student name and the second column is marks in tests.What we need to find is which student marks
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array. 01
c++ array find the average mark, highest mark, lowest mark, number of students passing,
c++ array find the average mark, highest mark, lowest mark, number of students passing,    i need help in adding the c++ code for the average mark, highest mark, lowest mark, number of students passing, using array. 01
Student average
to maintain this status is to maintain an average not below 1.8. write a java program... should display the average grade of the student and would display the message...: 1.2 Enter number of units: 1 you got an average of 1.59 congratulation
calculate average
and write a program and calculate your final average in this course. The details
Average Age of my Class?
Average Age of my Class?  average age of my class
sum and average of grades
sum and average of grades  how to print a program which is sum and average of Korean (90), English(85), Mathematics(78), Biology(65), Chemistry(83
Hibernate criteria average Example
Hibernate criteria average Example   How to find the average in Hibernate? Thanks   Example of finding average on a filed in Hibernate using criteria. For this you have to use Projections.avg() in your program. Check
compute the average of degrees
compute the average of degrees  using c++ language , write a program to do the following 1 enter three degrees of a student by the user . 2 compute the average of his degrees
How to calculate the average in Hibernate?
How to calculate the average in Hibernate?  Hi, I have to calculate the average in Hibernate. How to calculate the average in Hibernate? Thanks... of calculating the average on the fee field in database: Projections.avg("fee
SQL Average
SQL Average       SQL Average, the part of Aggregate Function. SQL Average is used to compute average value of the records in a table of the database. Understand
PHP Get Average - PHP
PHP Get Average  I am writing a method to calculate the average rating of the posted answers? can anyone help me with the method to calculate rating in PHP. In my code, we are providing maximum four options to the user to rate
Calculate sum and Average in java
Calculate sum and Average in java  How to calculate sum and average.... Description:- In this example we are calculating sum and average of n numbers... the sum by the total number of numbers, we have determined the average of numbers
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
Calculate an average Age of my Class?
Calculate an average Age of my Class?  average age of my class
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
MySQL Average Command
MySQL Average Command This example illustrates how to execute the Average command in MySQL. In this example we create a select query to find the average of 'lastAccess' field.   Query  
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
column matrix
column matrix  columan wise total matrix
column matrix
column matrix  columan wise total matrix
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend...(System.in); int array[]=new int[5]; System.out.println("Enter Array Elements
identify the order of the average running time of the method
identify the order of the average running time of the method  public static double getMedian (double[] A) { // given an ordered array of length n, return the median int n = A.length; if ((n % 2) == 1) return A[n/2]; else
Hibernate Criteria average example
Hibernate Criteria average example - Learn how to perform Hibernate Criteria Average Query Here we will use the avg() method of org.hibernate.criterion.Projections factory for getting the Projection instance for performing the average
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1