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

Ok, so what is his goal?

((I'm going to assume R means Rand, as in the South African currency, or you just weren't hitting "$" which is fine, and that's what I'm gonna do, but still considering you do actually mean Rand in which case I will do this over.))

Not only did you not provide enough info, you didn't even give us something to work off of, you'll have to come up with the main basis of the problem yourself.

EXAMPLE. If his goal is R"$"80,000, and all of the months he exceeds his amount,
(lets say he consistently gets R"$"73,000).

(Are you sure it's "0.7%" or "7%"??)

if 0.7%, then it'll be R"$"511
(( R"$"73,000 * 0.007 = 511 ))
and it'll take 13 years, or 156 months.

if 7%, then it'll be R"$"5,110
(( R"$"73,000 * 0.07 = 5,110 ))
and it'll take 1.3 years, or 15 months.

Now, it should be you that does the planning for the algorithm, this person is genuinely screwed if this is what he has going on(considering the R"$"511 a month and the goal for a house, which is usually around R"$"60k to R"$"80k
(going back to considering actual South African home sales, whether you actually screwed up or not I am considering both as I am using the American $ for the money, considering if this was actual ZAR currency, it would be around ZAR850k)

(But I'm just gonna assume your "$" key doesn't work or you weren't hitting it correctly and I highly doubt you are taking IT and asking about algorithms considering house prices and some guy named "Peter", these are grade school computer questions.)

.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.

To solve this problem, we can use a pre-test loop (while loop) because we do not know how many months it will take for Peter to reach his goal.

Here is the algorithm to solve the problem step by step:

1. Prompt the user to enter the goal amount to be saved (house cost) and the amount Peter can save per month.
2. Initialize the variables to keep track of the current total amount (totalAmount) and the number of months (numMonths) to 0.
3. Start a pre-test loop (while loop) with the condition: while totalAmount is less than the goal amount.
4. Inside the loop:
- If the totalAmount is less than R70,000, calculate the interest for the current month using the interest rate of 0.8% and add it to the totalAmount.
- Otherwise, if the totalAmount is equal to or more than R70,000, calculate the interest for the current month using the interest rate of 0.7% and add it to the totalAmount.
- Increment the numMonths by 1 to keep track of the number of months.
5. After the loop ends, display the final totalAmount and the number of months.

Pseudocode:

```
Display "Enter the goal amount to be saved (house cost): "
Read goalAmount

Display "Enter the amount Peter can save per month: "
Read monthlySaving

totalAmount = 0
numMonths = 0

While totalAmount < goalAmount
If totalAmount < 70000
interestRate = 0.008 // 0.8%
Else
interestRate = 0.007 // 0.7%

interest = totalAmount * interestRate
totalAmount = totalAmount + interest + monthlySaving
numMonths = numMonths + 1
End While

Display "Final Amount: ", totalAmount
Display "Number of Months: ", numMonths
```

This algorithm will continuously calculate the total amount with the interest and Peter's monthly savings until it reaches or exceeds the goal amount. The final total amount and the number of months are then displayed as output.

To solve this problem, we can use a post-test loop (a do-while loop) since we want to execute the loop at least once and then check the condition to continue with the loop.

Here is the algorithm to solve the problem:

1. Declare and initialize the following variables:
- goalAmount = 0 (to store the target amount)
- savingAmount = 0 (to store the amount Peter can save each month)
- currentAmount = 0 (to store the current amount Peter has)
- interestRate = 0.008 (to store the initial interest rate)

2. Read and store the goal amount and saving amount.

3. Set the loop counter variables:
- months = 0 (to store the number of months it takes to reach the goal)

4. Start the loop:
- Increment the months counter by 1.
- Add the savingAmount to the currentAmount.
- Check if the currentAmount is less than R70,000:
- If true, add the interestRate * currentAmount to the currentAmount.
- If false, set the interestRate to 0.007 and add the interestRate * currentAmount to the currentAmount.
- Check if the currentAmount is greater than or equal to the goalAmount.
- If true, exit the loop.

5. Display the final amount (currentAmount) and the number of months (months) it took to reach the goal.

Here is the algorithm in pseudocode:

```
Declare and initialize variables:
goalAmount = 0
savingAmount = 0
currentAmount = 0
interestRate = 0.008

Read and store goalAmount and savingAmount

Set loop counter:
months = 0

Do:
Increment months by 1
Add savingAmount to currentAmount

If currentAmount is less than R70,000:
Add interestRate * currentAmount to currentAmount
Else:
Set interestRate to 0.007
Add interestRate * currentAmount to currentAmount

While currentAmount is less than goalAmount

Display final amount (currentAmount) and number of months (months)
```

This algorithm will iterate the loop until the current amount becomes equal to or greater than the goal amount, considering the different interest rates based on the current amount.