Question: Integer userNumber is read from input. Write a while loop that iterates until userNumber is negative. At each iteration: Update integer outputVal as follows: If

Integer userNumber is read from input. Write a while loop that iterates until userNumber is negative. At each iteration: Update integer outputVal as follows: If userNumber is even, output "lose" and do not update outputVal. Otherwise, output "win" and increment outputVal. Then, read an integer from input into variable userNumber. End each output with a newline. Ex: If the input is 2 6 5 -5, then the output is: lose lose win Output value is 1 Note: x % 2 == 0 returns true if x is even.

Integer userNumber is read from input. Write a while loop that iteratesIn Java (Zybooks) please

Integer userNumber is read from input. Write a while loop that iterates until userNumber is negative. At each iteration: - Update integer outputVal as follows: - If userNumber is even, output "lose" and do not update outputVal. - Otherwise, output "win" and increment outputVal. - Then, read an integer from input into variable userNumber. End each output with a newline. Ex: If the input is 2655, then the output is: lose lose win Output value is 1 Note: x%2==0 returns true if x is even. \begin{tabular}{l|l} 1 & import java.util. Scanner; \\ 2 & \\ 3 & public class ResultCalculator \{ \\ 4 & public static void main(String[] args) \{ \\ 5 & Scanner scnr = new Scanner(System. in); \\ 6 & int userNumber; \\ 7 & int outputVal; \\ 8 & \\ 9 & outputVal =0; \\ 10 & userNumber = scnr.nextInt(); \\ 11 & \\ 12 & Y* Your code goes here */ \\ 13 & \\ 14 & System.out.println("Output value is " + outputVal); \\ 15 & \} \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!