Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:  

  1. UML Class diagram 
  2. Flowchart  
  3. Pseudo-code 
  4. Program Coded 
  5. 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... 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

Probability And Statistics

Authors: Morris H. DeGroot, Mark J. Schervish

4th Edition

9579701075, 321500466, 978-0176861117, 176861114, 978-0134995472, 978-0321500465

More Books

Students also viewed these Mathematics questions

Question

Explain how language develops.

Answered: 1 week ago