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

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);