168k views
3 votes
Write pseudocode to input any number of positive numbers and find the total

and the average. The user should enter -1' when they have finished entering
their list of positive numbers.

User Borka
by
8.6k points

1 Answer

5 votes

Answer:

Sure, here is a pseudocode to input any number of positive numbers and find the total and the average:

```

# Initialize variables

total = 0

count = 0

# Prompt the user to enter positive numbers

while True:

# Get a number from the user

number = input("Enter a positive number (-1 to finish): ")

# If the user entered -1, exit the loop

if number == "-1":

break

# If the number is positive, add it to the total and increment the count

if number > 0:

total += number

count += 1

# Calculate the average

average = total / count

# Print the total and average

print("The total is:", total)

print("The average is:", average)

```

Step-by-step explanation:

User Guillaume Le Floch
by
7.8k points