Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an array of Student class objects 1. Instead of creating one instance of the Student class, create an array of Student class objects. Create

Create an array of Student class objects

1. Instead of creating one instance of the Student class, create an array of Student class objects. Create the array as you would for any data type, but use Student objects, 16 elements EXAMPLE: Student [ ] arrayStudent = new Student [16];

2. Within the loop, input data from the data file into variables

3. Create a single instance of the Student class, using the constructor

4. Place the single instance of the Student class into the array of Student objects This completes loading the array with Student objects Retrieve data from the array of objects (this is to prepare for Labs 07 and 08)

5. Use a for/loop to go through the array of objects and print the report Within the loop, create a single instance of the Student class and move the object out of the array into the single instance

6. Use the class method to calculate the total, adjusted total and average

7. Do the following in the application program: For each student, look up their name from the student name file, using the student id. Do a sequential search from the file (not an array). Use a value returning method. The method will open and close the file for each student look-up. The method header needs throws FileNotFoundException Declare the student name file in the method Read the student id and student name, then compare student id to the search id Once the name is found (or name not found), close the file and return the name

8. Print the report (almost exactly as in Lab05 except add the student name)

PROGRAMMING STYLE I find it clearer to use single variables instead of subscripted variables, whenever possible. When reading the input student file, first place data into a variable Then create a single object. Then place the object into the array of objects. When retrieving data from the array of objects, return each object into a single object Methods: should have ONE exit point. For a value-returning method, this means one return statement

INPUT

File: Student file Lab06StudentFile.txt Record: Student record Field Data Type Student id# 4 numbers (ex. 1234) Ten test scores integers (valid numbers are 0 -100)

INPUT

File: Student name file Lab06Names.txt Record: Student name record Field Data Type Student id# 4 numbers (ex. 1234) Student name String

OUTPUT

File: Grade Report file Lab06Report.txt Record:

Student Grade Report

ID# Name /---------------------TEST Scores----------------------/ Total Adj Total Avg

xxxx xxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx xxxx xxx xxxx xxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx xxxx xxx xxxx xxxxxxxxxxxxxxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxxx xxxx xxx

//Student.java public class Student { private int inStudentId; private int [] inStudentGrades=new int[10]; //class default constructor public Student() { int tempArray [ ] = {0,0,0,0,0,0,0,0,0,0}; setStudentId (0); setStudentGradeArray(tempArray); }//end method public void setStudentGradeArray (int[] inStudentGrades) {//begin method for (int c = 0; chigh) high=inStudentGrades[i]; } return high; } //Returns lowest score public int getLowestScore() { int low=inStudentGrades[0]; for (int i = 1; i < inStudentGrades.length; i++) { if(inStudentGrades[i]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

2. What are your challenges in the creative process?

Answered: 1 week ago