Write a program that does the following:
Read two integers,
aandb, from the user input. These numbers define the range [a, b] (inclusive).Find all numbers within this range (including
aandb) that are divisible by 3.Calculate and print the mean (average) of these numbers.
Example: If the input range is [-5, 12], the numbers divisible by 3 are: -3, 0, 3, 6, 9, 12. The mean would be
Notes:
The input range will always contain at least one number divisible by 3.
Include both
aandbin your calculations if they are divisible by 3.
To calculate the mean, sum all integers divisible by 3 within the range, then divide this sum by the count of these integers. Consider using a separate counter variable, initialized to 0, to keep track of how many numbers are divisible by 3. Increment this counter each time you encounter such a number. This counter is a divisor when calculating the final mean.