i am not sure if the code i created is correct, it does run, but just not confident enough to say it is correct! it's not long, pls help!
Exercise question: Try creating a labeled while loop. Make the label outer and provide a condition to
check whether a variable age is less than or equal to 21. Within the loop, increment
age by one. Every time the program goes through the loop, check whether age is 16.
If it is, print the message "get your driver's license" and continue to the outer loop. If
not, print "Another year."
=====================My code is as below=======================
class ex52{
public static void main (
String args[]){
int age = 0;
outer:
while (age <= 21) {
if (age == 16) {
System.out.println ("Get your driver's license " + age);
} else {
System.out.println ("Another year " + age);
}
age++;
System.out.println ("incrementing age");
continue outer;
}
}
}