Final answer:
The question involves writing a program that calculates the average of inputted numbers that are divisible by 3. The pseudocode provided outlines the steps necessary, and a Python example demonstrates a possible implementation.
Step-by-step explanation:
To write a program that inputs N different numbers and finds the average of those numbers divisible by 3, you can use the following pseudocode as a guide:
- Ask the user for the total number N of numbers they will enter.
- Initialize two variables: 'sum' to 0 and 'count' to 0 to keep track of the sum of numbers divisible by 3 and their count respectively.
- Loop N times asking the user to input each number.
- Within the loop, check if the current number is divisible by 3. If so, add it to 'sum' and increment 'count' by 1.
- After the loop, check if 'count' is greater than 0 to avoid division by zero. If so, calculate the average by dividing 'sum' by 'count'.
- Output the average to the user. If 'count' is 0, inform the user that there were no numbers divisible by 3.
Here is an example of how the program could be implemented in Python:
def find_average_divisible_by_three():
N = int(input("Enter the number of values to input: "))
sum = 0
count = 0
for _ in range(N):
number = int(input("Enter a number: "))
if number % 3 == 0:
sum += number
count += 1
if count > 0:
average = sum / count
print("The average of numbers divisible by 3 is:", average)
else:
print("There were no numbers divisible by 3.")
find_average_divisible_by_three()