Question
Write a program that reads a sequence of names, ages, gpa-s, and zip codes for up to 50 students from an input file. Store the
Write a program that reads a sequence of names, ages, gpa-s, and zip codes for up to 50 students from an input file. Store the data in an array that has capacity to hold 50 Student objects. Keep track of number of students in variable count. Class Student has name, of String type, and age of int type, gpa of type double, and zip of String type. Assume that each line of input has name, age, gpa, zip data in this order and separated by a space.
Design class StudentList that has the following static methods for an array of Student type.
static void printList(Student[] list, int n) // prints all n students in the list
static int zipOfYoungest(Student[] list, int n) // returns the zip code of youngest student
//in the list
static Student oldestStudent(Student[] list, int n) // returns the oldest student in the list
static int countNewBritain((Student[] list, int n) // returns the number of students in zip 06050
static void printListReversed(Student[] list, int n) // prints students from n-th one
// down to the first one in the list.
Class Tester will have main method. In it read data from input file "inData.txt" into array studentList, assign variable count, and invoke each of the five methods. You should create an input file, and put data for 7 students in it.
First three students in the input file should be:
Sara 21 4.0 06050
Tommy 39 3.5 06111
Lisa 19 3.2 06050
and remaining four of your choice.
File should be in the same folder where all files from BlueJ for this program are located. Do not forget to append throws IOException to the main method header, and to use
import java.io.*;
import java.util.*;
clauses in the Tester class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started