Question: 5 9 7 7 0 8 . 4 3 9 2 2 7 4 . qx 3 zqy 7 Jump to level 1 Integer userIn

597708.4392274.qx3zqy7
Jump to level 1
Integer userIn is read from input. Write a while loop that iterates until userIn is negative. In each iteration:
Update integer finalVal as follows:
If userln is even, output "lose" and do not update finalVal.
Otherwise, output "win" and increment finalVal.
Then, read the next integer from input into variable userln.
End each output with a newline.
grad Click here for example
lose
win
lose
Final value is 1
Note: x%2==0 returns true if x is even.
import java.util.Scanner;
public class ResultCalculator {
public static void main(String[] args){
Scanner scnr = new Scanner(
System.in);
int userIn;
int finalVal;
finalVal =0;
userIn = scnr.nextInt();
}
System.out.println("Final value is "+ finalVal);
5 9 7 7 0 8 . 4 3 9 2 2 7 4 . qx 3 zqy 7 Jump to

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 Programming Questions!