Question: Java Collapse Implement a Person class that has the following private attributes: name (String) which contains both the first and last name age (int) favoriteFood

Java
 Java Collapse Implement a Person class that has the following private
attributes: name (String) which contains both the first and last name age

Collapse Implement a Person class that has the following private attributes: name (String) which contains both the first and last name age (int) favoriteFood (String) and the following methods: Constructor (that sets the name, age, favoriteFood from defined values). Get and set methods. Then create a PersonDemo class to create and use Person objects. The PersonDemo class contains the main method. Use a Scanner object to read the attributes for a Person object. Create a Person object by passing in the attributes read in by the Scanner object. Then print the name, age of the person and favoriteFood. Change the age by adding the ten years to the person's age and then reprint the person's information. Collapse The method header looks as follows: Input A name (first and last), followed by the person's age and their favourite food. Example Input: Sarah Jones 12 pizza Output The person's information on one line, followed by the person's information but ten years older on another line Example Output: Sarah Jones, 12, pizza Sarah Jones, 22, pizza Test 1 Check It

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!