I'm having trouble calling a function from a class (from another class). The very last call is the one with the error. here's the complete code:
import java.util.Scanner;
import java.util.Random;
import java.text.DecimalFormat;
//student class
class Student {
Scanner scan = new Scanner(System.in);
String Name, Address, Major;
double gpa;
Random generator = new Random();
DecimalFormat df = new DecimalFormat("#.##");
//constructor
public Student (String name, String address, String major){
Name = name;
Address = address;
Major = major;
computeGPA();
};
//default constructor
Student(String name, String address){
Name = name;
Address = address;
Major = "undefined";
computeGPA();
}
Student(){};
public void computeGPA() {
gpa = generator.nextFloat() * 3.51 + 0.5;
}
void listStudent(){
System.out.println("Name\taddress\tmajor\tgpa");
System.out.println(Name + "\t" + Address + "\t" + Major + "\t" + (df.format(gpa)));
}
}
public class Class
{
int studentcount = 0;
String classname, instructor;
int numofstudents;
double avGPA;
public Student[] studentlist = new Student[5];
//default constructor
void Class(String teacher)
{
instructor = teacher;
}
//increase size of array
void increaseSize()
{
Student[] temp = new Student[studentlist.length + 5];
for (int a = 0; a < studentlist.length; a++)
temp[a] = studentlist[a];
studentlist = temp;
}
//add a student
void addStudent(String enroll, String address)
{
if (studentcount == studentlist.length)
increaseSize();
studentlist[studentcount].Student(name, address);
}
}
and here's the error:
1 error found:
File: C:\Users\devon\Desktop\DevonLab7\Class.java [line: 83]
Error: C:\Users\devon\Desktop\DevonLab7\Class.java:83: cannot find symbol
symbol : variable name
location: class Class
___________________________________
any help would be GREATLY appreciated- thanks!