import java.util.*;
public class JavaApplication23{

    /**
     * @param args the command line arguments
     */
    static Scanner console = new Scanner(System.in);
    public static void main(String[] args)

    {
       //creat 5 arrays and declare 
        String [] Student= new String [10];
        int [] Quiz1  = new int [10];
        int [] Quiz2  = new int [10];
        int [] Quiz3  = new int [10];
        int [] Quiz4  = new int [10];
        int max , max1 = 0, max2 = 0, max3 = 0, max4 = 0;
        int min , min1 = 0, min2 = 0, min3 = 0, min4 = 0;
        double average ,average1 , average2 , average3, average4, sum; 
        String standing; 
        char letter;
        int I ; 
        double grades;


       // read elements to the 5 arrays
        for ( I = 0; I < Student.length; I++)
        {
            // read students name
            System.out.print("Enter a student name to the array ");
            Student[I]= console.next() ;
            System.out.println();

            // read Quiz 1
            System.out.print("Enter a grade for Quiz1 to the array ");
            Quiz1[I]= console.nextInt() ;
            System.out.println();

             // read Quiz2
            System.out.print("Enter a grade for Quiz2 to the array ");
            Quiz2 [I]= console.next().charAt(0);
            System.out.println();

            // read Quiz 3
            System.out.print("Enter a grade for Quiz3 to the array ");
            Quiz3[I]= console.nextInt() ;
            System.out.println();

            // read Quiz 4
            System.out.print("Enter a grade for Quiz4 to the array ");
            Quiz4[I]= console.nextInt() ;
            System.out.println();
        }


        //print out the header of the table
        System.out.println();
        System.out.println("______________________________________");
        System.out.println();
        System.out.println("Student\tQuiz1\tQuiz2\tQuiz3\tQuiz14");
        System.out.println("______________________________________");
        System.out.println();

         for ( I = 0; I < Student.length; I++)
        System.out.println( Student[I] + "\t" + Quiz1 [I] + "\t" + Quiz2 [I] + "\t" + Quiz3 [I] + "\t" + Quiz4 [I]);

        System.out.println();
        System.out.println("______________________________________");
         // read the max grade of the Quiz1

         max1 = Quiz1[0];
         for (int i = 0 ; I > Quiz1.length; i++)
             if (  Quiz1[i] > max1) 
                 min1 = Quiz1[i];
      System.out.println( "Max in Quiz1:  " + max1); 


          // read the max grade of the Quiz2
       max2 = Quiz2[0];
         for (int i = 0 ; I > Quiz2.length; i++)
             if (  Quiz2[i] > max2) 
                 max2 = Quiz2[i];
      System.out.println( "Max in Quiz2:  " + max2); 


           // read the max grade of the Quiz3
              max3 = Quiz3[0];
         for (int i = 0 ; I > Quiz3.length; i++)
             if (  Quiz2[i] > max3) 
                 max3 = Quiz3[i];
      System.out.println( "Max in Quiz3:  " + max3); 

          // read the max grade of the Quiz4
              max4 = Quiz4[0];
         for (int i = 0 ; I > Quiz4.length; i++)
             if (  Quiz4[i] > max4) 
                 max4 = Quiz4[i];
      System.out.println( "Max in Quiz4:  " + max4); 
        System.out.println("______________________________________");
        System.out.println();
        System.out.println(" ");

            // read the min grade of the Quiz1
              min1 = Quiz1[0];
         for (int i = 0 ; I < Quiz1.length; i++)
             if (  Quiz1[i] < min1) 
                 min1 = Quiz1[i];
      System.out.println( "Min in Quiz1:  " + min1); 

            // read the min grade of the Quiz2
              min2 = Quiz2[0];
         for (int i = 0 ; I < Quiz2.length; i++)
             if (  Quiz2[i] < min2) 
                 min2 = Quiz2[i];
      System.out.println( "Min in Quiz2:  " + min2); 

            // read the min grade of the Quiz3
              min3 = Quiz3[0];
         for (int i = 0 ; I < Quiz3.length; i++)
             if (  Quiz3[i] < min3) 
                 min3 = Quiz3[i];
      System.out.println( "Min in Quiz3:  " + min3); 

          // read the min grade of the Quiz4
              min4 = Quiz4[0];
         for (int i = 0 ; I < Quiz4.length; i++)
             if (  Quiz4[i] < min4) 
                 min4 = Quiz4[i];
      System.out.println( "Min in Quiz4:  " + min4); 
         System.out.println("______________________________________");
        System.out.println();
        System.out.println(" ");

        // read average of Quiz1
         average1 = Quiz1[0];
         for (sum = 0 ; I < Quiz1.length; I++)
         {
             sum = sum + Quiz1[I];
         }
         average= sum / 10;
      System.out.println( "Average of Quiz1 :  " + average); 

          // read average of Quiz2
         average2 = Quiz2[0];
         for (sum = 0 ; I < Quiz2.length; I++)
         {
             sum = sum + Quiz2[I];
         }
         average= sum / 10;
      System.out.println( "Average of Quiz2 :  " + average); 

          // read average of Quiz3
         average3 = Quiz3[0];
         for (sum = 0 ; I < Quiz3.length; I++)
         {
             sum = sum + Quiz3[I];
         }
         average= sum / 10;
      System.out.println( "Average of Quiz3 :  " + average);

          // read average of Quiz4
         average4 = Quiz4[0];
         for (sum = 0 ; I < Quiz4.length; I++)
         {
             sum = sum + Quiz4[I];
         }
         average= sum / 10;
      System.out.println( "Average of Quiz4 :  " + average); 

      //determine student standing

         average= console.nextDouble();
      if (average <= 9 & average >= 10 )
          standing="Excellent";

      else if (average >= 8 & average >= 7)
         standing="Good";

      else if (average >= 6 & average >= 5)
          standing="Satisfactory";
      else
          standing="Poor";
  System.out.println("your average is: " + standing);
    }
}

Recommended Answers

All 3 Replies

correcting what? does it compile? does it run? does it present a stacktrace? does it give unexpected results? .... ?
don't just copy paste some code without an explanation saying "solve the problems". we don't know what the progrem is supposed to do, so what can we tell?

sorry I forgot to explane the promblem I am facing.
this java code is about inserting students name and their grades in Quiz 1, 2, 3, and 4. I wrote a java code to make an array of the names and grades, and I have to get the minimum and maximum grade and the avarage of each quiz and their standing.

The problem is when I run the java code, I get the minimum and maximum grade is equal to each other. the other problem is I get the avarage of all quizes =0.0. ALthough I wrote the coding of the standing, but I still cannot get the standing while running the code.

first of all: organize your code in methods that you test one by one, that way it is easier to narrow down on what the problem might be at that point.

also, try and clear your code up a bit:

 else if (average >= 8 & average >= 7)
standing="Good";
else if (average >= 6 & average >= 5)
standing="Satisfactory";

these if statements make no sense.
you don't need the
'average >= 8 &' part in the first, nor the
'average >= 6 &' part in the second if 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.