Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Pet { String Name; String Type; int Age; int Height; int Weight; int Legs; public String getName() { return Name; } public void

public class Pet {

String Name;

String Type;

int Age;

int Height;

int Weight;

int Legs;

public String getName() {

return Name;

}

public void setName(String name) {

Name = name;

}

public String getType() {

return Type;

}

public void setType(String type) {

Type = type;

}

public int getAge() {

return Age;

}

public void setAge(int age) {

Age = age;

}

public int getHeight() {

return Height;

}

public void setHeight(int height) {

Height = height;

}

public int getWeight() {

return Weight;

}

public void setWeight(int weight) {

Weight = weight;

}

public int getLegs() {

return Legs;

}

public void setLegs(int legs) {

Legs = legs;

}

public void PrintStory(String TYPE,String NAME,int AGE,int HEIGHT,int WEIGHT,int LEGS){

System.out.println("There once was a "+TYPE+" named "+NAME+" who lived in Dallas, Texas. "+NAME+" was a "+LEGS+" legged pet."+

" In 2017, when it was "+AGE+" years old, "+NAME+" was "+HEIGHT+" feet tall and "+

WEIGHT+" pounds. "+NAME+" was a happy "+TYPE+" and had long and happy life.");

}

public static void main(String[] args){

Pet petObject=new Pet();

String name="Bruno";

String type="Pug";

int weight=14;

int legs=4;

int height=5;

int age=3;

petObject.setName(name);

petObject.setHeight(height);

petObject.setHeight(height);

petObject.setType(type);

petObject.setLegs(legs);

petObject.setWeight(weight);

petObject.setAge(age);

String NAME=petObject.getName();

int AGE=petObject.getAge();

String TYPE=petObject.getType();

int WEIGHT=petObject.getWeight();

int LEGS=petObject.getLegs();

int HEIGHT=petObject.getHeight();

petObject.PrintStory(TYPE, NAME, AGE, HEIGHT, WEIGHT, LEGS);

}

}

Need to modify this code so that the fields (name, type, age, weight, height and legs) are values entered by the user.

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions