Question
Design a program which solves the problem described in the problem statement below. Provide comments in your pseudo-code and Java program as necessary. It must
Design a program which solves the problem described in the problem statement below. Provide comments in your pseudo-code and Java program as necessary.
It must include these components:
- UML Class diagram
- Flowchart
- Pseudo-code
- Program Coded
- Program Output
Problem Statement
Design a class named Pet, which should have the following fields:
-
name: The name field holds the name of a pet.
-
type: The type field hold the type of animal that a pet is (for example, “dog”, “cat”, “bird”)
-
age: The age field holds the pet’s age.
The Pet class should also have the following methods:
-
setName: the setName method stores a value in the name field.
-
setType: the setType method stores a value in the type field
-
setAge: the setAge method stores a value in the age field.
-
getName: the getName method returns the value of the name field.
-
getType: The getType method returns the value of the type field.
-
getAge: the getAge method returns the value of the age field.
Once you have designed the class, design a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This data should be stored in the object. Use the object’s accessor methods to retrieve the pet’s name, type, and age and display this data on the screen.
Expected Output
Your results should be similar to the following:
Please enter the name of your pet: Maestro
Please enter the type of your pet: dog
Please enter the age of your pet: 8
The name of your pet is Maestro .
Maestro is a dog .
Maestro is 8 years old .
Step by Step Solution
3.48 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
Copyable code Class definition class Car Declaration of variables private int speed private String m...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