Question: Please answer question 1 and 2. Thank you! 1. 2. In the code below which line number is the loop control variable initialized? Line 1:


In the code below which line number is the loop control variable initialized? Line 1: Scanner keyboard = new Scanner(System.in); Line 2: System.out.print( "Enter your first positive integer: "); Line 3: int inputNumber = keyBoard.nextInt(); Line 4: Line 5: int sum 0; Line 6: int count = 0; Line 7: while(inputNumber != 0){ Line 8: sum += inputNumber; Line 9: count++; Line 10: System.out.print "Enter your next positive integer, or 0 to end: "); Line 11: inputNumber keyBoard.nextInt(); Line 12: } In the code below what is the value of the sentinel which would cause the loop to stop? Line 1: Scanner keyboard = new Scanner(System.in); Line 2: System.out.print( "Enter your first positive integer: "); Line 3: int inputNumber keyBoard.nextInt(); Line 4: Line 5: int sum = 0; Line 6: int count 0; Line 7: while(inputNumber != 0){ Line 8: sum += inputNumber; Line 9: count++; Line 10: System.out.print( "Enter your next positive integer, or 0 to end: "); Line 11: inputNumber = keyboard.nextInt(); ; Line 12:}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
