Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Integer valueIn is read from input. Write a while loop that iterates until valueIn is negative. In each iteration: Update integer outputVal as follows: If
Integer valueIn is read from input. Write a while loop that iterates until valueIn is negative. In each iteration:
Update integer outputVal as follows:
If valueIn is divisible by add valueIn to outputVal.
Otherwise, subtract valueIn from outputVal.
Then, read an integer from input into variable valueIn.
Click here for example
Ex: If the input is then the output is:
Output value is
Note: x returns true if x is divisible by import java.util.Scanner;
public class ResultCalculator
public static void mainString args
Scanner scnr new ScannerSystemin;
int valueIn;
int outputVal;
outputVal ;
valueIn scnrnextInt;
Your code goes here
System.out.printlnOutput value is outputVal;
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