Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A + Computer Science - Writing Classes Worksheet 2 DIRECTIONS : Fill in each blank with the proper java code. class Pet { private String

A+ Computer Science - Writing Classes Worksheet 2
DIRECTIONS : Fill in each blank with the proper java code.
class Pet
{
private String name;
private int age;
public Pet(String n, int a)
i
(1)
}
public void setAge( int a )
{
(2)
}
public void setName ( String n )
q
(3)
}
public String getName()
q
(4)
}
public int getAge()
q
(5)
}
public string tostring()
{
(6)
}
}//runner code
Scanner kb = new Scanner (System.in);
for (int r=1; r=5; r++){
System.out.print (" Enter a pet name ::");
String n = kb.next();
System.out.print (" Enter a pet age ::");
String n = kb.nextInt();
Pet pet = new Pet( n, a );
System.out.println (pet);
}
image text in transcribed

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

More Books

Students also viewed these Databases questions

Question

What are some of the possible scenes from our future?

Answered: 1 week ago