Implement a grade book IN JAVA! and IF you need to use scanner then please use S
ID: 3834051 • Letter: I
Question
Implement a grade book IN JAVA! and IF you need to use scanner then please use StringTokenizer and Buffered Reader.
continued..
This is what the StudentType.java file has:--------------------------------------------------------------------------------------------------------
In lab 8 you will be writing a class that uses the StudentType class ou will find Student e.iava a good starting place). The new class is a "roster Type" needed to implement a Student Gradebook to be used to grade a course. Your portion of the program will need to maintain infomation for a maximum class size of 20 students. The interface specification is class rosterType Constructor to initialize the class roster to an empty state ready to receive students to a maximum of 20 students. public rosterType Tells whether or not the class is empty or full public boolean is Full public boolean is Empty Add a new student to the class in SID sorted order If the class is full do nothing, discard the student. public void addstudent (StudentType ent Return the student specified by the student id If no student matches the id, return an empty student. public Student Type findstudent String sid tostring method returns the entire class as a string with tabs between fields of a student and newlines between students public string tostring printBy Grade prints out the entire class sorted by the total grade each student has earned. Additionally, the method will output the mean score the average score and the median score the middle value or the average of the two middle values in an even number of scores. boobie tofuhead 878-51-7051 96 stinky rhinohonker 175-12-7353 91Explanation / Answer
import java.util.Arrays;
class rosterType {
StudentType[] students;
int count=0;
public rosterType()
{
students=new StudentType[20];
}
public boolean isFull()
{
if(count==20)
{
return true;
}
return false;
}
public boolean isEmpty()
{
if(count==0)
{
return true;
}
return false;
}
public void addStudent(StudentType newStudent)
{
if(!isFull())
{
students[count]=newStudent;
for (int j = 1; j < count; j++) {
StudentType key = students[j];
int i = j-1;
while ( (i > -1) && ( students [i].getSID().compareTo(key.getSID())>1 ) ) {
students [i+1] = students [i];
i--;
}
students[i+1] = key;
}
count++;
}
}
public StudentType findStudent(String sid)
{
StudentType s=null;
for(int i=0;i<count;i++)
{
if(students[i].getSID()==sid)
{
s=students[i];
return s;
}
}
return s;
}
public String toString()
{
String s="";
if(!isEmpty())
{
StudentType[] temp=Arrays.copyOf(students,20);
for (int j = 1; j < count; j++) {
StudentType key = temp[j];
int i = j-1;
while ( (i > -1) && ( temp [i].getTotal()>key.getTotal() ) ) {
temp [i+1] = temp [i];
i--;
}
temp[i+1] = key;
}
double sum=0;
double mean=0;
for(int i=0;i<count;i++)
{
s=temp[i].getFname()+" "+temp[i].getLname()+" "+temp[i].getFormatedSID()+" "+temp[i].getTotal()+" ";
sum=sum+temp[i].getTotal();
}
mean=sum/count;
s=s+" Mean :"+mean+" ";
double median=0;
int actualindex=count-1;
if(count%2==0)
{
median= (temp[actualindex/2].getTotal() + temp[(actualindex/2) +1].getTotal() )/2;
}
else
{
median=temp[(actualindex/2)].getTotal();
}
s=s+" Median :"+median+" ";
}
return s;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.