dimanche 8 mars 2015

How can I get java's random generator to produce a double for variable in a constructor statement?

Preface: I am new at this. Here is the source code file that won't compile because I get the error message that "method next double in class Random cannot be applied to given types."





import java.util.Random;
public class Student
{
private String name;
private String address;
private String major;
private double GPA;

Random generator = new Random();

public Student (String studName, String studAddr, String studMaj)
{
name = studName;
address = studAddr;
major = studMaj;
GPA = generator.nextDouble(.5, 4.0);
}

public Student (String studName, String studAddr)
{
name = studName;
address = studAddr;
major = "undeclared";
GPA = generator.nextDouble(.5, 4.0);
}







Aucun commentaire:

Enregistrer un commentaire