You will get email Reply within few hours

Thursday, 16 May 2013

Lab 6 java

I have one last project concerning a program in Java using arrays and files. It basically calculates GPA among students which is a text file using a line reader class.

Anyhow, let me know if your interested and I wouldn't need this until monday of next week... 8/13

Thanks for your time


---------------------------

Problem Description:
You are given a text file called ‘Students.txt' that contains information on many students. Your program reads the file, creating mainy Student objects, which will be stored in an array of Student objects in the Students class. The Driver class controls everything, calling many Students class methods o produce lots of different reports.

File and class specifications
Students.txt file format
Information for each student is stored in the file as 3 lines of text:

name
age
GPA

e.g. the following shows data for two students:

Name 0
22
1.2
Name1
22
2.71

Your program must work for a file containing any number of students.

Student class
The Student class represents one student. Your Student class must have exactly and only the following instance variables:

private String name;
private int age;
private double gpa;

Design appropriate constructors and methods for your Student class, including:

+ toString() - returns a String containing the 3 instance variables e.g.

Name0     22     1.2

Students class
The Students class is used to store and process many Student objects. Your Students class must have exactly and only the following instance variables:

public static final int MAX = 100; //max # of Student objects in array

private Student students[]; //array of Student objects
private int count; // maintain # of objects in array

The students array here is a partial array of Student objects, in which all of the Student objects are stored.

Students will have appropriate constructors and methods, including the following:

+ readFile() - reads the data file, creates Student objects, and puts them into the students array

+ toString() - returns a String containing a ine of information for each Student in the students array. Will call Student's to String() to do this. For example:

Name0     22     1.2
Name1     22     2.71

Many other methods for processing a Students object. Most of the code you write will be in this class.

LineReader class
Your program will read from the data file using the LineReader class.

Driver class
The Driver class controls everthing. Driver contains only a main() method, which creates a Students object then calls many Students methods. Driver does not have any instance variables. In pseudocode:

+ main()     create an empty Students object

(the actions below will be implemented as public Students methods, called from main() using appropiate parameters and return types)

read file into Students
print all Student objects from Students
print the Student with the best GPA
calculate and print the average GPA
print all the Students with GPAs above the average
sort the Student objects in Students into ascending order of GPA
print all Student objects from Students again (will now be in a different order)


Hints
•     here's a method that sorts an array of ints. You need to alter the syntax for your program. Do not use API sort methods for this.

public void sortIntArray(int arr[])
{
     int i, j, temp;
     int max = arr.length;

     for (i = 1; i < max; ++i) {
          temp = arr;
          j = i – 1;
          while (j >= 0 && temp < arr[j]) {
               arr[j + 1] = arr[j];
               j = j – 1;
          }
          arr[j + 1] = temp;
     }
}

•     where possible, your Students methods should return results rather than print them out. This makes the methods more general and useful, because the calling method then has the choice to print returned value, or use it in some other way


Required:
•     Your program must clearly label each part of the output e.g. “Student with best GPA:”, “Average GPA is:”, “Students with GPA's above average:”, etc
•     Use good programming practices regarding encapsulation of class instance variables i.e. all must be declared private



EMAIL ME For Solution:
topsolutions8@gmail.com