Question: I will attach the code that I received from a different answer, however i am receiving these two errors Person.java:79: error: class, interface, or enum

 I will attach the code that I received from a differentanswer, however i am receiving these two errors Person.java:79: error: class, interface,

I will attach the code that I received from a different answer, however i am receiving these two errors

Person.java:79: error: class, interface, or enum expected Student.java; ^ Person.java:152: error: class, interface, or enum expected Test.java; ^ 2 errors

This is the code

public class Person {

//Declaring variables private String name; private String gender; private int birthYear; //Zero argumented constructor public Person() { super(); this.name="Tom Hammond"; this.gender="??"; this.birthYear=1900; } //Parameterized constructor public Person(String name, String gender, int birthYear) { super(); this.name = name; this.gender = gender; this.birthYear = birthYear; } //Setters and getters public void set(String name, String gender, int birthYear) { this.name = name; this.gender = gender; this.birthYear = birthYear; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getGender() { return gender; } public void setGender(String gender) { this.gender = gender; } public int getBirthYear() { return birthYear; } public void setBirthYear(int birthYear) { this.birthYear = birthYear; }

//This method will Display Person info public void display() { System.out.println("Name=" + name +" "+ gender + " born in "+ birthYear); }

@Override public String toString() { System.out.println("Name=" + name +" "+ gender + " born in "+ birthYear); return ""; } }

Student.java

public class Student extends Person { //Declaring variables private String major; private double gpa; private int creditHours;

public Student() { } //Parameterized constructor public Student(String name, String gender, int birthYear, String major, double gpa, int creditHours) { super(name, gender, birthYear); this.major = major; this.gpa = gpa; this.creditHours = creditHours; } //Setters and getters public void set(String name, String gender, int birthYear) { super.set(name, gender, birthYear); } public void setStudent(String major, double gpa, int creditHours) { this.major = major; this.gpa = gpa; this.creditHours = creditHours; } public String getMajor() { return major; } public void setMajor(String major) { this.major = major; } public double getGpa() { return gpa; } public void setGpa(double gpa) { this.gpa = gpa; } public int getCreditHours() { return creditHours; } public void setCreditHours(int creditHours) { this.creditHours = creditHours; }

//This method will display Student class object info public void display() { super.display(); System.out.println( "major :" + major + " gpa=" + gpa + " "+ creditHours + " credit hours to graduate."); }

}

Test.java

public class Test {

public static void main(String[] args) { Person p1=new Person("Sally","Female", 1998); Person p2=new Person(); Student [] studs=new Student[2]; for(int i=0;i

}

}

9:26 PM 71% o AT&T KAssn15 Assign15-2.docx Write an error-free Java program to do the following things. Implement a class called Person. A person has a name, gender and a birth year. Make a Class Student that inherits from Person. A student has a major, a gpa and a number of credit hours completed. Write the class declarations for Person and Student. The main0 module is shown below. You must write the class definitions, constructor(s) and method(s) to make the program work. The output from the given main0 is shown after main. Your output can be formatted differently be displayed. For example, when the Student information is displayed, the program show their name, gender, birth year as well as the major, gpa and credits till graduation. If the data has not been set via a method, then the default value is displayed. Remember to put the usual header at the top of the program and to submit via Canvas. Main code: 5 public class assign15 soln 7 public static void main (String arg) 9 Person pl new Person ("Sally female 1998) 10 Person p2 new Person Student studs new Student 12 13 for (int i 0; i

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!