Question
Using simple Java: Write a class called Dog that contains instance data that represents the dogs name as a String and weight in pounds, as
Using simple Java:
Write a class called Dog that contains instance data that represents the dogs name as a String and weight in pounds, as a double. In addition, the class should have the following methods:
A default constructor, which initializes name to dog and weight to 0
A getter for each instance data
A setter for each instance data
A method toKgs() that computes and returns the weight of the dog in kilograms (1lb = 0.453592 kg).
A toString() method that returns a one-line description of the dog including name and weight.
Write an application Kennel that instantiates two Dog objects and updates the names and weights with data from the user. The program will display the information about each object (Hint: toString() method) as well as the average weight in kilograms.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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