Final answer:
The question involves writing a program to count positive, negative, and zero numbers as entered by the user until they decide to stop.
Step-by-step explanation:
To write a program that allows a user to enter numbers repeatedly and afterward displays the count of positive numbers, negative numbers, and zeros entered, we can employ a simple while loop that continues to accept input until the user decides to stop. The program would typically use three counters to keep track of the quantity of each type of number entered. Below is a python snippet that accomplishes this task:
positive_count = 0
negative_count = 0
zero_count = 0
while True:
user_input = input("Enter a number (or 'q' to quit): ")
if user_input.lower() == 'q':
break
try:
number = int(user_input)
if number > 0:
positive_count += 1
elif number < 0:
negative_count += 1
else:
zero_count += 1
except ValueError:
print("Please enter a valid number or 'q' to quit.")
print(f"Positive numbers: {positive_count}")
print(f"Negative numbers: {negative_count}")
print(f"Zeros: {zero_count}")
This Python code counts positive numbers, negative numbers, and zeros until the user types 'q' to quit. Input validation is included to ensure the user enters a valid number.