Intro to programming concepts: JAVA 1 Code a do-while loop that keeps printing t
ID: 3811006 • Letter: I
Question
Intro to programming concepts: JAVA 1Code 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. Intro to programming concepts: JAVA 1
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. Intro to programming concepts: JAVA 1
Explanation / Answer
public class Sample1 {
public static void main(String args[]){
char misbehaving;
misbehaving='y';
do
{
System.out.println("I have to mind my teacher!");
}
while(misbehaving=='y');
}
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.