Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use scnr . nextInt ( ) to read remaining integers from input into inputValue until - 1 0 0 0 is read. For each integer

Use scnr.nextInt() to read remaining integers from input into inputValue until -1000 is read. For each integer read before -1000:
If the integer is positive, output the integer followed by " found" and increment countOfPositive.
Otherwise, output the non-positive integer.
End each output with a newline.
Ex: If the input is 95-1410-1000, then the output is:
9 found
5 found
-14
10 found
Positive integers occur 3 time(s)
Note: The sentinel value is -1000.
import java.util.Scanner;
public class CountOfPositive {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
int inputValue;
int countOfPositive;
countOfPositive =0;
inputValue = scnr.nextInt();
while (/* Your code goes here */){
/* Your code goes here */
}
System.out.println("Positive integers occur "+ countOfPositive +" time(s)");
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Identify the universal properties of all languages.

Answered: 1 week ago