Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed
image text in transcribed
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

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

Step: 3

blur-text-image

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions