Question: Use scnr . nextInt ( ) to read remaining integers from input into dataValue until 1 0 0 0 is read. For each integer read
Use scnrnextInt to read remaining integers from input into dataValue until is read. For each integer read before :
If the integer is nonnegative, output the integer followed by spotted" and increment numCounts.
Otherwise, output the negative integer.
End each output with a newline.
Ex: If the input is then the output is:
spotted
mathrm spotted
spotted
Nonnegative integers occur times
Note: The sentinel value is
import java.util.Scanner;
public class NumCounts
public static void mainString args
Scanner scnr new Scanner
System.in;
int dataValue;
int numCounts;
numCounts ;
while true
dataValue scnrnextInt;
System.out.printlnNonnegative integers occur numCounts times;
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
