Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Integer userIn is read from input. Write a while loop that iterates until userIn is negative. In each iteration: Integer userIn is read from input.
Integer userIn is read from input. Write a while loop that iterates until userIn is negative. In each iteration: Integer userIn is read from input. Write a while loop that iterates until userIn is negative. In each iteration:
Update integer finalNum as follows:
If userIn is divisible by output "win" and increment finalNum.
Otherwise, output "lose" and do not update finalNum.
Then, read the next integer from input into variable userln.
End each output with a newline.
Click here for example
Ex: If the input is then the output is:
win
win
lose
Einal number is
Note: returns true if is divisible by Scanner scnr new ScannerSystemin;int finalNum;userIn scnrnextInt;if userIn else finalNum;userIn scnrnextInt;
Update integer finalNum as follows:
If userIn is divisible by output "win" and increment finalNum.
Otherwise, output "lose" and do not update finalNum.
Then, read the next integer from input into variable userIn.
End each output with a newline.
Click here for example
Ex: If the input is then the output is:
win
win
lose
Final number is
Note: x returns true if x is divisible by
everything is right but can't get the final number is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started