//Trevor Potter
// Nov. 11,2014
import java.util.*;
public class student
{
        public static void main (String [] args)
        {
                int[] student= new int [20];
                int[] exam1= new int[20];
                int[] exam2= new int[20];
                int[] exam3= new int[20];
                int[] avg= new int[20];
                int i=0;




                Scanner input = new Scanner(System.in);
                for(i=0; i<=19; i++){
                System.out.println(" Enter grade for student:" + student[i]+ "(exam1, exam2, exam3)");

                exam1[i]=input.nextInt();
                exam2[i]=input.nextInt();
                exam3[i]=input.nextInt();
                avg[i] = (exam1[i]+exam2[i]+exam3[i])/3;
        }

                System.out.println(" ");
                System.out.println("Student  Exam1  Exam2  Exam3  Average");
                for(i=0; i<=19; i++)
                {
                System.out.println(student[i]+"    "+exam1[i]+"   "+exam2[i]+"   "+exam3[i]+"    "+avg[i]);
                }
        }// end of class
}// end of main

Recommended Answers

All 3 Replies

It would help if you can be a bit more descriptive about your question related to your sample code. just dont assume that someone is going to read your title, look at your code and provide you with the correct response.

also, moving this thread to java since you had posted it to javascript. java and javascript is not the same nor are they related other than the fact that they both share "java" in their name.

the array student is created on line 8 but you have no code to inialise it, so it is just full of zeros. So on line 20 when you print student[i] that's always zero.

i figured it out it was student[i]=i+1 before my system.out.print statement

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.