This site requires JavaScript, please enable it in your browser!
Greenfoot back
NewbJava
NewbJava wrote ...

2021/2/16

instantiate objects help

NewbJava NewbJava

2021/2/16

#
public class Classes {
public static void main(String[] args) { 
    //1. write a code that instantiates at least 10 different students (a few with the same last name and the same GPA)   
   
    Student s1 = new Student(3.7, 12,Johnson,Fred); 
} 
}
public class Student{
 private double gpa;
 private int creditHrs;
 private String fname;
 private String lname;
 public Student(double gpa, int creditHrs, String fname, String lname)
 {
 this.gpa = gpa;
 this.creditHrs = creditHrs;
 this.fname = fname;
 this.lname = lname;
 }
NewbJava NewbJava

2021/2/16

#
how do I instantiate 10 different students. There is an error were it says "Cannot find symbol Variable" for both Johnson and Fred
danpost danpost

2021/2/17

#
NewbJava wrote...
how do I instantiate 10 different students. There is an error were it says "Cannot find symbol Variable" for both Johnson and Fred
Literal strings need to be between double quote marks.
You need to login to post a reply.