Question: Can I adopt a pet? Given a variable personAge, code a conditional statement that will allow one of the following to be printed: You can
Can I adopt a pet?
Given a variable personAge, code a conditional statement that will allow one of the following to be printed:
"You can adopt a pet!" if you are at least years old.
"You are not old enough to adopt a pet!" otherwise.
Assume that you have to be at least years old to adopt a pet!
Solution
Reset
Java
if canAdoptPet
Sample Test Case #
Execute code
STDOUT
CodingQuestion.java:: error: cannot find symbol
CanAdoptPet true;
symbol: variable CanAdoptPet
location: class CodingQuestion
CodingQuestion.java:: error: cannot find symbol
CanAdoptPet false;
symbol: variable CanAdoptPet
location: class CodingQuestion
errors
Expected STDOUT
You are not old enough to adopt a pet!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
