go to previous page   go to home page   go to next page

Answer:

No—each group can have a different number of students in it.


Start on the Program

import java.io.*;
import java.util.Scanner;

class TestGroups
{
  public static void main ( String[] args ) throws IOException
  {
    int value;     // the value of the current integer
    
    // Prompt for and open the input file   
    Scanner user = new Scanner( System.in );
    System.out.print("File name? ");
    String fileName = user.next().trim();
    Scanner scan = new Scanner( new File(fileName) );  

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

    sizeA  = scan.nextInt();

    int count = ______ ; // initialize count

    while ( count < ______ )
    {
      value = scan.nextInt();
      ______________; // add to the sum
      ________; // increment the count
    }

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

QUESTION 9:

Fill in the missing code.