Answered step by step
Verified Expert Solution
Link Copied!

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 5, 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 15,5,11-9, then the output is:
win
win
lose
Einal number is 2
Note: x%5==0 returns true if x is divisible by 5. Scanner scnr = new Scanner(System.in);int finalNum;userIn = scnr.nextInt();if (userIn %5==0){} else { finalNum++;userIn = scnr.nextInt();
}
Update integer finalNum as follows:
If userIn is divisible by 5, 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 15511-9, then the output is:
win
win
lose
Final number is 2
Note: x %5==0 returns true if x is divisible by 5.
everything is right but can't get the final number is 2
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions