Question: specs for DetectPositiveNumbers DetectPositiveNumbers For this assignment you are going to write code for the following ONE class called DetectPositiveNumbers with a main method. what

specs for DetectPositiveNumbers

 

DetectPositiveNumbers

For this assignment you are going to write code for the following ONE class called DetectPositiveNumbers with a main method. what it does: -- it reads an unspecified number of integers. It counts how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). -- it ends when it detects the input 0. -- it displays the average as a floating-point number. If only 0 is entered, the program should print: no numbers are entered except 0

Restrictions

Do not use arrays, lists, maps, or any other data structure.

Here are some sample runs:

% java DetectPositiveNumbers Enter integers below, program ends when 0 is entered: 1 -1 2 -2 0 The number of positives is 2 The number of negatives is 2 The total is 0 The average is 0.0 % java DetectPositiveNumbers Enter integers below, program ends when 0 is entered: 3 3 3 4 0 The number of positives is 4 The number of negatives is 0 The total is 13 The average is 3.25 % java DetectPositiveNumbers Enter integers below, program ends when 0 is entered: 10 0 The number of positives is 1 The number of negatives is 0 The total is 10 The average is 10.0 % java DetectPositiveNumbers Enter integers below, program ends when 0 is entered: 6 2 2 0 The number of positives is 3 The number of negatives is 0 The total is 10 The average is 3.3333333333333335 % java DetectPositiveNumbers Enter integers below, program ends when 0 is entered: -6 -2 -2 0 The number of positives is 0 The number of negatives is 3 The total is -10 The average is -3.3333333333333335 % java DetectPositiveNumbers Enter integers below, program ends when 0 is entered: 0 no numbers are entered except 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!