138k views
5 votes
(2) Design pseudocode for a program that accepts numbers from the user until the special number 555 is entered (you should use an indefinite loop for this.) After the user enters the special value, your program should output the number of numbers entered AND the sum of those numbers.

1 Answer

2 votes

Answer:

Pseudocode is explained below

Step-by-step explanation:

# Create a variable to count the numbers.

numberOfNumbers = 0

# Create a variable to store the sum of numbers.

sumOfNumbers = 0

# Create a constant to store the special numbers.

constant specialNumber = 222

# Start the loop.

while True:

{

# Prompt the user to enter a number.

num = input("Enter a number: ")

# Break the loop if the number is

# equal to the special number.

if num == 222:

{

break

}

# Otherwise, add the number in the current

# sum and increment the number of values.

else:

{

sumOfNumbers = sumOfNumbers + num

numberOfNumbers = numberOfNumbers + 1

}

}

# Display the values.

print("The number of numbers = ", numberOfNumbers)

print("The sum of numbers = ", sumOfNumbers)

User JGerulskis
by
5.4k points