A good answer might be:

The near-complete program is given below.


Half-complete Program

The following program computes the average for group "A". The average is computed using double precision floating point, even though the two quantities involved are both of type int. To do this, a type cast is used to convert sumA into a double so that the division is floating point division, not integer division.

import java.io.*;
class TestGroups
{
  public static void main ( String[] args ) throws IOException
  {
    String line;
    BufferedReader stdin = new BufferedReader( 
        new InputStreamReader( System.in ) );
    int value;     // the value of the current integer

    // Group "A"
    int sizeA;     // the number of students in group "A"
    int sumA = 0;   // the sum of scores for group "A"

    System.out.println("How many students in group A:");
    line   = stdin.readLine();
    sizeA  = Integer.parseInt( line.trim() );

    int count = 0; // initialize count

    while ( count < sizeA )
    {
      System.out.println("Enter a number:");
      line   = stdin.readLine();
      value  = Integer.parseInt( line.trim() );
      sumA  = sumA + value ; // add to the sum
      count = count + 1; // increment the count
    }

    if ( sizeA > 0 )
      System.out.println( "Group A average: " + ((double) sumA)/sizeA ); 
    else
      System.out.println( "Group A  has no students" );
  
    // Group "B"
  
    . . . .  more code will go here . . . . 
  }
}

QUESTION 10:

If you were writing this program on your own, what would be a nice thing to do at this point?