Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone tell me where is the error and fix it please the code + its java -------------------- package person; public class Person { public

image text in transcribed
can someone tell me where is the error and fix it please
the code + its java
--------------------
package person;
public class Person {
public static void main(String[] args) {
person p1 = new person("Hala", 20, 55, 160);
person p2 = new person();
person p3 = new person();
System.out.println(p1.Display());
System.out.println(p2.Display());
System.out.println(p3.Display());
boolean equalIsResult = person.equals(p1.getAge(), p2.getAge());
if (equalIsResult) {
System.out.println("Person1 and person2 are same age");
} else {
System.out.println("Person1 and person2 are different age");
}
if (person.isAdult(p3)) {
System.out.println("Person3 is adult");
} else {
System.out.println("Person3 is NOT adult");
}
System.out.println("number of objects: " + person.objNum);
}
}
class person {
public static int objNum = 0;
private String name;
private int age;
private double weight;
private double height;
public person() {
this("none", 0, 0.0, 0.0);
}
public person(String name, int age, double w, double h) {
this.name = name;
this.age = age;
this.weight = w;
this.height = h;
objNum++;
}
public void getAge(int age) {
this.age = age;
}
public String Display() {
return "name: " + this.name + ",age: " + this.age + "weight:" + this.weight + "height: " + this.height;
}
public static boolean equals(int p1, int p2) {
if (p1 == p2) {
return true;
} else {
return false;
}
}
public static boolean isAdult(person p) {
if (p.age
return false;
} else {
return true;
}
}
}
I. PESMI .. SM System, IEEE 1 Car ayus All : Tode tal 1. Odens string Oly pl title Plan

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions