hello! can you help me debug my program? it's in Java. here are my errors: line 155: void is an invalid type for the variable printOutFamilyline 126: the method content(String) is undefined for the type String here is my program: package family;   class Person { private String name; private int age;   public Person() { }   public Person(String name, int age) { this.name = name; this.age = age; }     public String toString() { return "Person [name: "+ name + ", age: " + age+ "]"; }   @Override public boolean equals(Object obj) { if(this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Person other = (Person) obj; if(age != other.age)return false; if(name == null) { if(other.name !=null) return false; } else if (!name.contentEquals(other.name)) return false; return true; }   public String getName() { return name; }   public void setName(String name)  { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; }   }   class Student extends Person { private String major; private double gpa;   public Student(String name, int age, String major, double gpa) { super(name, age); this.major = major; this.gpa = gpa; }   public Student() { }   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 String toString()  { return "Student [major: "+ major +", GPA: " +gpa + ", name: "+ getName() + ", age: " + getAge() + "]"; }   @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; Student other = (Student) obj; if(gpa != other.gpa) return false; if (major == null) { if(other.major != null) return false; } else if (!major.content(other.major)) return false; return true; }   }   public class Family  { private Person familyPersons[]; private int numPersons = 0;   public Family(int num)  { familyPersons = new Person[num]; } private void addPerson(Person p) { for (int i =0; i < numPersons; i++) { if(familyPersons[i].equals(p)) { System.out.println("Duplicate entry: "+p); return; } } if (numPersons != familyPersons.length) { familyPersons[numPersons++] = p; } else { System.out.println("Famuly array full. Skippin: " +p);   } } private void printOutFamily; { for(int i = 0; i < numPersons; i++) { System.out.println(familyPersons[i]);   }   }   private void printOutFamily() { for(int i = 0; i < numPersons; i++) { System.out.println(familyPersons[i]); } }   public static void main(String[] args) { Family f = new Family(8); Person fred = new Person("Fred Flintstone", 50); System.out.println("created " + fred); f.addPerson(fred);; f.addPerson(fred);;   Student fredStudent = new Student("Fred Flintstone", 50, "Math", 3.1); System.out.println("created "+fredStudent); f.addPerson(fredStudent);   Person wilma = new Person("Wilma Flintstone", 48); f.addPerson(wilma);;   Student george = new Student("George", 21, "politics", 3.1); System.out.println("created " + george); f.addPerson(george);   george.setName("Georgie");   f.addPerson(new Student("George", 21, "Politics", 3.1)); f.addPerson(new Student("John", 18, "Geology", 2.9)); f.addPerson(new Student("Jane", 21, "music", 3.2)); f.addPerson(new Student("Tarzan", 22, "Gymnastics", 4.0)); f.addPerson(new Student("Jim", 21, "Physics", 2.5)); f.addPerson(new Person("Robert", 18)); f.addPerson(new Person("Clemente", 32));   System.out.println("******** family listing: "); f.printOutFamily();   } }

Question

hello! can you help me debug my program? it's in Java.

here are my errors:

line 155: void is an invalid type for the variable printOutFamily
line 126: the method content(String) is undefined for the type String

here is my program:

package family;

 

class Person {

private String name;

private int age;

 

public Person() {

}

 

public Person(String name, int age)

{

this.name = name;

this.age = age;

}

 

 

public String toString()

{

return "Person [name: "+ name + ", age: " + age+ "]";

}

 

@Override

public boolean equals(Object obj)

{

if(this == obj)

return true;

if (obj == null)

return false;

if (getClass() != obj.getClass())

return false;

Person other = (Person) obj;

if(age != other.age)return false;

if(name == null) {

if(other.name !=null)

return false;

}

else if (!name.contentEquals(other.name))

return false;

return true;

}

 

public String getName()

{

return name;

}

 

public void setName(String name) 

{

this.name = name;

}

public int getAge()

{

return age;

}

public void setAge(int age)

{

this.age = age;

}

 

}

 

class Student extends Person {

private String major;

private double gpa;

 

public Student(String name, int age, String major, double gpa)

{

super(name, age);

this.major = major;

this.gpa = gpa;

}

 

public Student()

{

}

 

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 String toString() 

{

return "Student [major: "+ major +", GPA: " +gpa + ", name: "+ getName() + ", age: " + getAge() + "]";

}

 

@Override

public boolean equals(Object obj)

{

if (this == obj)

return true;

if (!super.equals(obj))

return false;

if (getClass() != obj.getClass())

return false;

Student other = (Student) obj;

if(gpa != other.gpa)

return false;

if (major == null)

{

if(other.major != null)

return false;

}

else if (!major.content(other.major))

return false;

return true;

}

 

}

 

public class Family 

{

private Person familyPersons[];

private int numPersons = 0;

 

public Family(int num) 

{

familyPersons = new Person[num];

}

private void addPerson(Person p)

{

for (int i =0; i < numPersons; i++)

{

if(familyPersons[i].equals(p))

{

System.out.println("Duplicate entry: "+p);

return;

}

}

if (numPersons != familyPersons.length)

{

familyPersons[numPersons++] = p;

}

else

{

System.out.println("Famuly array full. Skippin: " +p);

 

}

}

private void printOutFamily;

{

for(int i = 0; i < numPersons; i++)

{

System.out.println(familyPersons[i]);

 

}

 

}

 

private void printOutFamily()

{

for(int i = 0; i < numPersons; i++)

{

System.out.println(familyPersons[i]);

}

}

 

public static void main(String[] args) {

Family f = new Family(8);

Person fred = new Person("Fred Flintstone", 50);

System.out.println("created " + fred);

f.addPerson(fred);;

f.addPerson(fred);;

 

Student fredStudent = new Student("Fred Flintstone", 50, "Math", 3.1);

System.out.println("created "+fredStudent);

f.addPerson(fredStudent);

 

Person wilma = new Person("Wilma Flintstone", 48);

f.addPerson(wilma);;

 

Student george = new Student("George", 21, "politics", 3.1);

System.out.println("created " + george);

f.addPerson(george);

 

george.setName("Georgie");

 

f.addPerson(new Student("George", 21, "Politics", 3.1));

f.addPerson(new Student("John", 18, "Geology", 2.9));

f.addPerson(new Student("Jane", 21, "music", 3.2));

f.addPerson(new Student("Tarzan", 22, "Gymnastics", 4.0));

f.addPerson(new Student("Jim", 21, "Physics", 2.5));

f.addPerson(new Person("Robert", 18));

f.addPerson(new Person("Clemente", 32));

 

System.out.println("******** family listing: ");

f.printOutFamily();

 

}

}

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Write the DEFINITION/IMPLEMENTATION (write the code) of the class movie declaration in Question 2. ...

A: Given://Movie.h#include &lt;iostream&gt;#include &lt;string&gt;#include &lt;cmath&gt;using namespace...

Q: How could we determine EF if there is no percentage given?

A: Determination of Exposure Factor (EF) The Exposure Factor denotes a loss percentage for a specific ...

Q: hey I was wondering if someone could explain to me in this snippit why I get an error when I try to ...

A: ISSUES in CODE: - ArrayList&lt;DecoyForDogNapper&gt; List = new ArrayList&lt;&gt;(); Don't use obj...

Q: //the language is java What is an event?  Why do you need to handle the event?  How do you handle an...

A: EVENT Events are the notification that something has happened to the application.  As the user clic...

Q: C++

A: Following is the C++ program that takes as input from user the value of x. Then using the while loop...

Q: Provide the all possible spanning trees of a complete rectangular graph (recall the definition of a ...

A: Click to see the answer

Q: Use a direct proof to show that the sum of two odd integers is even.

A: Click to see the answer

Q: Given the following, what is assigned to the lvalue? integer = int('9.9') A. 9 B. 9.9 C. 10 D. None ...

A: ANSWER: Based on two statements, one can predict the answer for the given question. “int ('9.9')”- ...

Q: Write a query to display the movie title, movie year, price description, and price rental fee for al...

A: From the given details, we are creating a sample table, with name Movies: