Write a program, using for–repeat nested loop, to accept salaries from the user and calculate the average salary. The following algorithm would be adopted:
1. Ask the user to enter the total number of months.
2. Ask the user to enter the monthly salary one by one.
3. Check if the salary amount is between $5,000 and $20,000 inclusively.
4. If the amount exceeds the range, print an error message and require the user to re–enter the amount.
5. Output the average salary.
A sample program output is shown below:
Enter the total number of months: 3
Enter salary for month 1: 15000
Enter salary for month 2: 3000
Out of range
Enter salary for month 2: 30000
Out of range
Enter salary for month 2: 7000
Enter salary for month 3: 11000
The average salary is 11000.00