import java.util.ArrayList;
public class course
{
// instance variables
ArrayList students;
ArrayList grades;
private InputReader reader;
double sum;
double totalgrades;
double avg;
double highgrade;
double lowgrade;
/**
* Constructor for objects of class course
*/
public course()
{
//
students = new ArrayList();
grades = new ArrayList();
reader = new InputReader();
highgrade = highgrade;
lowgrade = 999999;
}
/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public void addStudnet()
{
info newstudent;
String name;
boolean finished = false;
String gradeSt;
double grade;
welcome();
while(!finished)
{
System.out.println(" Enter the name of the student");
name = reader.getInput();
if(name.startsWith("bye"))
{
finished = true;
System.out.println("Good Bye");
}
else
{
System.out.println(" Enter a grade");
gradeSt = reader.getInput();
System.out.println("Done");
grade = Double.parseDouble(gradeSt);
newstudent = new info(name , grade);
students.add(newstudent);
// totals up the grades(used in the Average method)
sum = sum + grade;
if (grade > highgrade)
{
highgrade = grade;
}
if (grade < lowgrade)
{
lowgrade = grade;
}
/*if (gradeSt.compareTo(lowgrade) < 0)
{
lowgrade.equals(newstudent);
}*/
// totals up the number of grades.
totalgrades++;
}
}
}
public void welcome()
{
System.out.println("Type bye to leave");
}
public void printStudents()
{
int ndx;
for (ndx =0; ndx< students.size(); ndx++)
System.out.println(students.get(ndx));
}
public void printHighandLow()
{
System.out.println(highgrade);
System.out.println(lowgrade);
}
public void getAverage()
{
avg = sum/totalgrades;
System.out.println(" Average = "+ avg );
}
}