convert the while loop in the following code to a do-while loop: Scanner keyboar
ID: 3540925 • Letter: C
Question
convert the while loop in the following code to a do-while loop:
Scanner keyboard = new Scanner(System.in);
int x = 1;
while (x > 0)
{
System.out.print("Enter a number: ")
x = keyboard.nextInt();
}
Explanation / Answer
Scanner keyboard = new Scanner(System.in);
int x = 1;
do
{
System.out.print("Enter a number: ")
x = keyboard.nextInt();
} while (x > 0);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.