Question
Please help me with my CSE lab Please copy the following code into your IDE and ensure it compiles. public class Student { private String
Please help me with my CSE lab
Please copy the following code into your IDE and ensure it compiles. public class Student
{
private String name; private int age; private String major; private int studentID; private double GPA;
public Student(){
}
public void setName(String name)
{
this.name = name;
}
private String setGPA()
{
return this.GPA;
}
private String setStudentID()
{
return this.GPA;
}
}
In the Student class define set and get method for all classs variables. Ive already defined some setters and they have different visibility. Try to call them in main function in Lab9 class. And find which type you can call which you cant.
Complete the constructor of Student. Set the default value:name = Alice,age =18,major= computer science, studentID=1212345678,GPA=3.56.
Create another constructor to accept five parameters from user. And create a new Student instance with this constructor.
Hint:Passing five parameters when you create new instances of Student.
Create another constructor to accept three parameters(name,age and studentID) and create a new Student instance with this constructor.
Hint:Passing name,age,StudentID when you create new instances of Student.
Add a displayStudent() function in the Student class to print out all the variables in the student class. Call this function for each instances you create above in Lab9 and see what information it prints.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started