Question: This is a Java program Write a program that reads an unspecified number of integers, determines home many positive and negative values have been read,

This is a Java program

Write a program that reads an unspecified number of integers, determines home many positive and negative values have been read, and computes the total and average of the input values (not counting zeros). Your program ends with the input 0. Display the average as a floating-point number to 2 decimal places.

System.out.println(countPositive); System.out.println(countNegative); System.out.println(total); System.out.printf("%.2f",total * 1.0 / count);

Assume inputs are always integer [-912985153, 912985153] and ends with 0.

Input

1 2 -1 3 0

Output

3

1

5

1.25

NOTE:

1- When the input is 0 , that means, user didn't enter anything and so the expected output is single zero 0 .

// Do not count zero as positive or negative number!

2- You need to read all the inputs in one single line with one space between each number. Exactly like the provided examples. Do not add extra spaces.

3- The output needs to be in separate lines.

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!