Returning string in java using 3 parameters
- by user2905118
Need to write a method describePerson() that takes 3 parameters, a String giving a person’s
name, a boolean indicating their gender (true for female, false for male), and an integer giving their age. The method should return a String formatted as in the following examples:
Lark is female. She is 2 years old.
Or
Jay is male. He is 1 year old.
I am not sure how to write it correctly (my code):
int describePerson(String name, boolean gender, int age) {
String words="";
if(gender==true) return (name + "is "+gender+". "+"She is"+age+ "years old.);
else
return (name + "is "+gender+". "+"She is"+age+ "years old.);
}
The outcome "year" and "years" is also differs, but i don't know how to make it correct..