in java Integer valueIn is read from input. Write a while loop that iterates until valueIn is negative. In each iteration: Update integer result as follows: If valueIn is divisible by 5, output "win" and increment result. Otherwise, output "lose" and do not update result. Then, read an integer from input into variable valueIn. End each output with a newline.   Click here for exampleEx: If the input is 5 15 11 -5, then the output is:   win win lose Result is 2   Note: x % 5 == 0 returns true if x is divisible by 5. import java.util.Scanner; public class ResultCalculator {   public static void main(String[] args) {      Scanner scnr = new Scanner(System.in);      int valueIn;      int result;         result = 0;      valueIn = scnr.nextInt(); /your code here/       System.out.println("Result is " + result);   }}

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 14E
icon
Related questions
Question

in java

Integer valueIn is read from input. Write a while loop that iterates until valueIn is negative. In each iteration:

  • Update integer result as follows:
    • If valueIn is divisible by 5, output "win" and increment result.
    • Otherwise, output "lose" and do not update result.
  • Then, read an integer from input into variable valueIn.

End each output with a newline.

 

Click here for exampleEx: If the input is 5 15 11 -5, then the output is:

 

win win lose Result is 2

 

Note: x % 5 == 0 returns true if x is divisible by 5.

import java.util.Scanner;

public class ResultCalculator {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int valueIn;
      int result;
   
      result = 0;
      valueIn = scnr.nextInt();

/your code here/

      System.out.println("Result is " + result);
   }
}

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr