Write code for a JOptionPane dialog that will ask whether th

Write code for a JOptionPane dialog that will ask whether the user is at least 18 years of age. Then set the boolean variable adult equal to either true, if the user is at least 18, or false otherwise. Include the declaration of the variable adult. What output is produced by the following code? int code - 2; switch (code) case 1: System.out.println(\"Hello.\"); case 3: System.out.printIn(\"Good-bye.\"); break; default: System.out.printIn(\"Till we meet again.\"); break;) Rewrite the following block using nested if: if (x 0) sign = 1;

Solution

2)))))))))))))

output:

till we met again.

as there is no 2 the default case will be executed

3))))))))))))))

if(x<0)

{

sign=-1;

}

else if (x==0)

{

sign=0;

}

else

{

if(x>0)

{

sign=1;

}

}

 Write code for a JOptionPane dialog that will ask whether the user is at least 18 years of age. Then set the boolean variable adult equal to either true, if th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site