





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






System.out.println(); }
**
//File Student.java import java.util.ArrayList; import java.util.Iterator; public class Student { private String fName; private String lName; private ArrayList
public void setLastName(String lName) { this.lName = lName; } public void setScores(ArrayList
int total = 0.0; for ( int k = 0; k < list.length; k++ ) total += list[k]; double average =(int)((double)total/list.length + 0.5); System.out.println( “Average “ + average );
int max = list[0]; int min = list[0]; for ( int k = 0; k < list.length; k++ ) { if ( list[ k ] > max ) max = list[ k ]; if ( list[ k ] < min ) min = list[ k ]; } System.out.println( “Smallest “ + min + “ Largest “ + max );
public void add( double item ) { count++; sum += item; if ( count == 1 ) { min = item; max = item;} else if ( item < min ) min = item; else if ( item > max ) max = item; } //Accessors public int getCount() { return count; } public double getMean() { return mean; } public double getMinimum() { return min; } public double getMaximum() { return max; } } Write an application that builds a DataSet object for the gpa’s of a set of students. First, input the individual gpa’s, and add them to the DataSet (negative value to terminate loop). After entering all gpas, report whether the gpa is above, equal to, or below the average gpa of the set. public class ProcessGPAs { public static void main( String[] args ) { Scanner inp = new Scanner( System.in ); DataSet set = new DataSet(); System.out.println(“Enter student GPA’s ending with -1.0”); double gpa = inp.nextDouble(); while ( gpa >= 0.0 ) { set.add( gpa ); gpa = inp.nextDouble(); } double mean = set.getMean(); System.out.println(“Output gpa status for all students: ”); while ( inp.hasNext() ); { gpa = inp.nextDouble();