Code to be written in R code:
Correct answer will be awarded brainliest!
General idea of this problem: You have just graduated from your university and just started your first job. You plan to buy a flat on your own which has price = $1,200,000 (1.2 million dollars). You need to save money for several years before you can afford to make the down payment which is 25% of the flat’s price.
Call the amount that you have saved thus far: saved. You start the very first month with a savings of $10,000 that your parents gave you.
Call your monthly salary as salary which is paid at the end of every month.
Each month, you are going to dedicate 40% of your salary to save for the down payment.
Assume that you invest your savings wisely, with a monthly average return of 2%. That means at the end of each month, you receive an additional of saved × 0.02 funds where saved is the amount you have from end of previous month to put into your savings.
At the end of each month, your savings will be increased by the return on your investment, plus 40% of your monthly salary.
Note: In your code for the questions below, you MUST use the names as given in bold above.
1. Write the code to calculate how many months it will take you to save up enough money for the down payment for two persons of different salary:
(i) salary = $7,000; and (ii)salary = $10,000.
2. In question above, we unrealistically assumed that the salary doesn’t change over the years. However, now we consider that the salary will be raised every 4 months by a rate named rate, this variable should be in decimal form (0.03 for 3%). The new salary will be applied for the month after every batch of 4 months.
With this further assumption, write the code to calculate how many months it will take a person to save up enough money for the down payment if that person has
(i) (salary = $7,000 and rate = 0.02) and
(ii) (salary = $10,000 and rate = 0.01).