Here is a Python program that reads an unspecified number of integers, counts the number of positive and negative values, calculates the total and average of the non-zero inputs:
```python
def read_input():
numbers = []
while True:
num = int(input("Enter an integer (enter 0 to exit): "))
if num == 0:
break
numbers.append(num)
return numbers
def count_positive_negative(numbers):
positive_count = 0
negative_count = 0
for num in numbers:
if num > 0:
positive_count += 1
elif num < 0:
negative_count += 1
return positive_count, negative_count
def calculate_average(numbers):
total = sum(numbers)
count = len(numbers)
average = total / count
return average
input_numbers = read_input()
positive_count, negative_count = count_positive_negative(input_numbers)
average = calculate_average(input_numbers)
print("Positive count:", positive_count)
print("Negative count:", negative_count)
print("Total:", sum(input_numbers))
print("Average:", average)
```
Example Output:
```
Enter an integer (enter 0 to exit): 5
Enter an integer (enter 0 to exit): -3
Enter an integer (enter 0 to exit): 0
Positive count: 1
Negative count: 1
Total: 2
Average: 1.0
```
Write a program that reads an unspecified number of integers, determines how 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.
1 answer