Question
JAVA!! Please help me fix the code. public class PersonApp { private String name; private int age; private double income; public PersonApp() { name =
JAVA!! Please help me fix the code.
public class PersonApp { private String name; private int age; private double income;
public PersonApp() { name = " "; age = 0; income = 0.0; } public PersonApp(String n, int a, double i) { name = n; age = a; income = i; } public String getName() { return name; } public int getAge() { return age; } public double getIncome() { return income; } public void setName(String n) { name = n; } public void setAge(int a) { age = a; } public void setIncome(double i) { income = i; } public boolean equals(Object anotherPerson) { return(name.equalsIgnoreCase((PersonApp)anotherPerson.name()) && age == ((PersonApp)anotherPerson.age() && Math.abs(income - ((PersonApp)anotherPerson.income()) < 0.01); } }
public class TestPersonApp { public static void main(String[] args) { PersonApp person = new PersonApp("m",23,0); System.out.println("Name: " + person.getName()); System.out.println("Age: " + person.getAge()); System.out.println("Income: " + person.getIncome()); } }
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