Question: Use scnr . nextInt ( ) to read integers from input into inputNumber until - 9 9 is read. For each remaining integer read before
Use scnrnextInt to read integers from input into inputNumber until is read. For each remaining integer read before if the integer is nonzero, output the integer followed by a newline and add the integer to sumOfSelected.
Ex: If the input is then the output is:
The sum of all nonzero values is import java.util.Scanner;
public class SumOfSelected
public static void mainString args
Scanner scnr new ScannerSystemin;
int inputNumber;
int sumOfSelected;
sumOfSelected ;
Your code goes here
System.out.printlnThe sum of all nonzero values is sumOfSelected;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
