0

public class Student {

private String name;
private String address;
private String phone;
private String major;

String[] classesTaken = new String[100];
double[] gradesRecived = new double[100];

public void addClassesTaken (String classID) {}
public void addGradeReived(float classGrade){}
public void changeGradesRecieved(String classID, double newGrade){}
public double computeGPA( ) { }

}

I need to randomly fill the gradesReceived array with random values between 0 and 100. I need instant variables private. I need to Populate the class taken whth an empty string. they can both be within the same loop

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by javaAddict
0

For the random generated numbers try : Math.random(); . It will return a random double between 0 and 1. You can then multiply with 100 and cast it to an int

I need to Populate the class taken whth an empty string

Add getters and setters for the variables: name, address, phone, major and call them after you have created an instant of the object. Example:

public void setName(String name) {
  this.name=name;
}

public String getName() {
  return name;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.