| | |
Could somebody help me please with java program?
![]() |
•
•
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,765
Reputation:
Solved Threads: 493
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
| Thread Tools | Search this Thread |
addball android api applet application apps array automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse ee error eventlistener exception expand fractal free game gis givemetehcodez graphics gui guidancer html ide image inetaddress integration intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia jvm linux loan loop map method migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program project radio scanner server service set sharepoint smart sms smsspam software sortedmaps sql subclass support swing textfield threads tree trolltech unlimited utility windows






