Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I want to implement a method in a code which shows me the paramaters and details of an object I created my code is below
I want to implement a method in a code which shows me the paramaters and details of an object I created
my code is below here. But I did not see any results in a Console when I run the code. How can I achieve the requested result
List studentList = new
ArrayList();
studentManagement student1 = new studentManagement(101,"Berkay",(float)3.6);
studentManagement student2 = new studentManagement(102,"Kaan",(float)3.8);
studentManagement student3 = new studentManagement(103,"Yaman",(float)3.6);
studentManagement student4 = new studentManagement(101,"Berkay",(float)3.6);
studentManagement student5 = new studentManagement(102,"OG",(float)3.0);
showStudent(student1);
}
public void showStudent(studentManagement student) {
String output = student.toString();
System.out.println(output);
}
public String toString() {
return this.studentID + ", " + this.studentname + "," + this.GPA;
package workshop;
import java.util.ArrayList;
import java.util.List;
import java.util.*;
public class studentManagement {
public int studentID;
public String studentname;
public float GPA;
public static void main(String[] args) {
// TODO Auto-generated method stub
}
public studentManagement(int studentID, String studentname, float gPA) {
super();
this.studentID = studentID;
this.studentname = studentname;
this.GPA = gPA;
}
public void inputStudent() {
List studentList = new ArrayList();
studentManagement student1 = new studentManagement(101,"Berkay",(float)3.6);
studentManagement student2 = new studentManagement(102,"Kaan",(float)3.8);
studentManagement student3 = new studentManagement(103,"Yaman",(float)3.6);
studentManagement student4 = new studentManagement(101,"Berkay",(float)3.6);
studentManagement student5 = new studentManagement(102,"OG",(float)3.0);
showStudent(student1);
}
public void showStudent(studentManagement studentz) {
System.out.println(toString());
}
public String toString() {
return studentID + ", " + studentname + "," + GPA;
}
public int getStudentID() {
return studentID;
}
public void setStudentID(int studentID) {
this.studentID = studentID;
}
public String getStudentname() {
return studentname;
}
public void setStudentname(String studentname) {
this.studentname = studentname;
}
public float getGPA() {
return GPA;
}
public void setGPA(float gPA) {
GPA = gPA;
}
}
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