3.Do the planning and write algorithm to solve for following problem.



There are 15 pupils in the Introduction to Programming I module. The age of every student is entered in years and months. Convert the age into months to calculate the average age. Display the answer (average age) in years and months on screen.



4.Do the planning and write an algorithm for the following questions. Each problem contain a do loop. When planning your algorithm, decide which type of loop will be best suited to solving the particular problem (pre-test or post-test). If the problem contain a decision to be made, decide whether you’ll use an if statement or a select case statement. You can assume that all the input data for the following questions will be valid.



Peter decided to save money to buy a house. Enter this amount as well as the amount he will be able to save each month. He earns 0.8% interest per month while the amount is less than R70,000 and 0,7% interest per month if the amount is equal to or more that R70,000. The interest is added to the total amount. Calculate how many months he will have to save before he has reached his goal. Display the final amount and the number of months.

Peter decided to save money to buy a house. Enter this amount as well as the amount he will be able to save each month. He earns 0.8% interest per month while the amount is less than R70,000 and 0,7% interest per month if the amount is equal to or more that R70,000. The interest is added to the total amount. Calculate how many months he will have to save before he has reached his goal. Display the final amount and the number of months.

Score >=90, 80-89,70-79,60-69,50-59,>=50 Grade A+, A, B, C, D, F write an algorthn

To solve the first problem, which is to calculate the average age of the students in months, we can follow these steps:

1. Initialize a variable named "totalAge" to 0.
2. Create a loop to iterate through each student's age.
3. For each student, convert their age into months and add it to the "totalAge" variable.
4. After the loop, calculate the average age by dividing the "totalAge" variable by the total number of students (in this case, 15).
5. Display the average age on the screen, both in years and months.

Here's the algorithm in pseudocode:

```
Set totalAge = 0

For each student in Introduction to Programming I module
Read student's age in years and months
Convert age to months
Add converted age to totalAge
End For

Calculate averageAge = totalAge / 15

Convert averageAge to years and months

Display averageAge
```

-----------

To solve the second problem, which is to calculate how many months Peter will have to save before reaching his goal, given the amount he can save each month and the interest rates based on the amount saved, we can follow these steps:

1. Read and store the amount Peter wants to save as "goalAmount" and the amount he can save each month as "monthlySaving".
2. Initialize variables:
- "finalAmount" to 0
- "interestRate" to 0.008 (0.8% expressed as a decimal)
- "months" to 0
3. Create a loop to iterate until the "finalAmount" reaches or exceeds the "goalAmount".
4. Inside the loop, check the value of the "finalAmount":
- If "finalAmount" is less than 70000, set "interestRate" to 0.008 (0.8%).
- Otherwise, set "interestRate" to 0.007 (0.7%).
- Add the monthly interest to the "finalAmount" by multiplying it with "interestRate" and adding it to "finalAmount".
- Add 1 to the "months" variable.
- Add the monthly savings to the "finalAmount".
5. Display the final amount reached and the number of months it took to reach the goal.

Here's the algorithm in pseudocode:

```
Read goalAmount
Read monthlySaving

Set finalAmount = 0
Set interestRate = 0.008
Set months = 0

While finalAmount < goalAmount
If finalAmount >= 70000
Set interestRate = 0.007
End If

Set finalAmount = finalAmount + (finalAmount * interestRate) + monthlySaving
Set months = months + 1
End While

Display finalAmount
Display months
```