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!");
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.