| | |
Could somebody help me please with java program?
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jun 2008
Posts: 1
Reputation:
Solved Threads: 0
I have two arrays. In the first one I have student surnames, in second the student grades. (One surname one line with grades).My task is to find the arithmetic average for each student and print that student name and grade which have the biggest grade in array. I wrote the program which can find arithmetic average for one student and print his name and grade. Can somebody help to write another part of program? Here is text of my program:
Sorry about my English
java Syntax (Toggle Plain Text)
package md4; import java.util.Scanner; public class Main { public static void main(String[] args) { String surnames[]= {"Alksnis", "Berzinsh", "Celms", "Dadzis", "Eglitis", "Zalitis"}; int grades [][] = { {6, 6, 7, 7, 8, 5}, {5, 6, 4, 9, 5, 7}, {6, 6, 5, 6, 6, 7}, {9, 8, 8, 9, 9, 8}, {8, 7, 7, 8, 8, 7}, {7, 5, 6, 5, 7, 6} }; double result = 0; int u; double arifm; int i=0,j=0; //i=row, j=column Scanner input = new Scanner( System.in ); System.out.println("0. Alksnis, 1. Berzinsh, 2. Celms, 3. Dadzis, 4. Eglitis, 5. Zalitis"); // surnames i = input.nextInt(); // read number from user System.out.println("priekkshmetu skaits no 1-6"); u = input.nextInt(); // read number from user for (j=0; j<u; j++) //choise how many grades result= result + grades [i][j]; //summ of elements arifm = result / j; System.out.println(surnames [i]+ " arithmetic average is " +arifm ); } }
Last edited by Ancient Dragon; Aug 10th, 2008 at 4:59 pm. Reason: add code tags
•
•
Join Date: Jan 2008
Posts: 3,844
Reputation:
Solved Threads: 503
You have a 6 x 6 array of grades. You have the code that computes the average for one person. You need to compute the average for all six, so stick that code into a loop that executes 6 times (once per person). Have a variable called
highestAverage . Initialize it to the average of the first person. As you compute each average, compare arifm to highestAverage . If arifm is bigger than highestAverage , set highestAverage to arifm . When you are done with the loop, you'll have the highest average stored in highestAverage . ![]() |
Similar Threads
- put the Dos 's command into java program? (Java)
- Running java command thru java program (Java)
- Help with Java program writing (Java)
- Java program sample for getting Systeminfo (Java)
- JAVA program help (Student/Grades) (Java)
- Help with a java program home work assignment (Java)
Other Threads in the Java Forum
- Previous Thread: need help with jbutton and new jframe
- Next Thread: how to Round off Floats in Java
Views: 548 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
911 addball addressbook android api append apple applet application arguments array arrays automation binary bluetooth button chat class classes client code component css csv database draw eclipse ee error event exception file fractal game givemetehcodez graphics gui helpwithhomework html ide image input integer j2me java javaarraylist javaprojects jmf jni jpanel julia jvm key linux list loan loop map method methods mobile netbeans newbie number object oracle output packets phone print problem program programming project recursion reporting robot scanner screen se server service set size sms socket software sort sql stream string swing test threads time transfer tree ubuntu windows wrong






