Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java 1: Need help with C. 1b. Code a do-while loop that keeps printing the messa

ID: 3864595 • Letter: J

Question

Java 1: Need help with C.

1b. Code a do-while loop that keeps printing the message “I have to mind my teacher!” as long as the student keeps misbehaving in class. Assume misbehaving and input (for the Scanner class) are already declared. The variable misbehaving has been initialized to ‘y’ and it’s the loop-control variable.

char misbehaving;

     

       misbehaving='y';

       do

       {

           System.out.printf("I have to mind my teacher!");

       }

       while(misbehaving=='y');

C. Re-code 1b using a while loop with a priming read:

Explanation / Answer

Answer:

char misbehaving;

     

       misbehaving='y';

       while(misbehaving=='y')

       {

           System.out.printf("I have to mind my teacher!");

       }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote