Text To PDF LnNText To PDF LnNText To PDF LnNText To PDF LnNText To PDF LnNText To PDF LnNText To PDF LnNText To PDF LnN
/ 6

public class Student
{
private static final int NUM_EXAMS = 4;
private String firstName;
private String lastName;
private int gradeLevel;
private double gpa;
private int[] exams;
private int numExamsTaken;
/**
* This is a constructor. A constructor is a method
* that creates an object -- it creates an instance
* of the class. What that means is it takes the input
* parameters and sets the instance variables (or fields)
* to the proper values.
*
* Check out StudentTester.java for an example of how to use
* this constructor.
*/
public Student(String fName, String lName, int grade)
{
firstName = fName;
lastName = lName;
gradeLevel = grade;
exams = new int[NUM_EXAMS];

numExamsTaken = 0;
}
public double getAverageScore()
{
int sum = 0;
for(int i = 0; i < exams.length;i++)
{
sum+=exams[i];
}
return (double)sum/numExamsTaken;
}
public String getName()
{
return firstName + " " + lastName;
}
public void addExamScore(int score)
{
exams[numExamsTaken] = score;
numExamsTaken++;
}
// This is a setter method to set the GPA for the Student.
public void setGPA(double theGPA)
{
gpa = theGPA;

}
/**
* This is a toString for the Student class. It returns a String
* representation of the object, which includes the fields
* in that object.
*/
public String toString()
{
return firstName + " " + lastName + " is in grade: " + gradeLevel;
}
}
//Randomizer code
import java.util.*;
public class Randomizer{
public static Random theInstance = null;
public Randomizer(){
}
public static Random getInstance(){
if(theInstance == null){
theInstance = new Random();
Loading document...
/ 6
Upload to Download
Every 3 documents you upload earns 1 download credit.
You have uploaded 0 documents. Upload 3 more to earn a download.
Upload Documents