Question: so this is to file one of them called student.java another one called studentdemo.java i have already wrote the following code. Just edit it and

 so this is to file one of them called student.java anotherone called studentdemo.java i have already wrote the following code. Just edit

so this is to file one of them called student.java

another one called studentdemo.java

i have already wrote the following code. Just edit it and make it works it will be good to me! thanks! And add comments please!

public class Student { //attributes private String name; private String id; private int startYr; private int gradYr; //constructor public Student(String name,String id,int startYr,int gradYr) { this.name=name; this.id=id; this.startYr=startYr; this.gradYr=gradYr; } public void setname(String n) { name=n; } public void setid(String i) { id=i; } public void setstartYr(int st) { startYr=st; } public void setgradYr(int gr) { gradYr=gr; } public String getname() { return name; } public String getid() { return id; } public int getstartYr() { return startYr; } public int getgradYr() { return gradYr; } public String toString() { return "name:"+name+"id: "+id; } }

////////////////////////////////////

import java.util.*; public class StudentDemo{ public static void main(String []args) { Scanner kb=new Scanner(System.in); String name,id; int startYr,gradYr; name=kb.next(); id=kb.next(); startYr=kb.nextInt(); gradYr=kb.nextInt(); Student a=new Student(name,id,startYr,gradYr); a.Student(name,id,startYr,gradYr); a.Student.setname(name); } }

Implement a Student class that has the following private attributes: name (String) . id (String) startYr (int) gradYr (int) and the following methods: Constructor (that sets the name, id, startYr, gradYr from defined values) .Get and set methods toString() method returns the name and ID of the student Then create a StudentDemo class to create and use Student objects. The StudentDemo class contains the main method. Use a Scanner object to read the attributes for a Student object. Create a Student object by passing in the attributes read in by the Scanner object

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!