0
//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

Edited by JorgeM: Moved to the Java forum category

3
Contributors
3
Replies
16
Views
2 Years
Discussion Span
Last Post by Trevor_4
0

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.

0

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.

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.