Assignment 1
Assignment 1
NAME: TILAGAVATHI A/P ARUMUGAM ID: 11107205993010 CONTACT NUM: 016-9625640 E-MIAL: [email protected]
QUESTION:
The rule of n72 is used to make a quick estimate of the time required for prices to double due to inflation. If the inflation rate is r percent, then the Rule of 72 estimates that prices will double in 72/r years. For instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. Write a program to test the accuracy of this rule. The program should display a table showing, for each value of r from 1 to 20, the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (Assume prices increase at the end of each year). Figure below shows the first few rows of of the output.
RULE OF 72
72 36 24
ACTUAL
72 36 24
PSEUDOCODE
FOR R = 1 to 20 RULE = 72/r IF (rule integer (rule)) > 0 THEN Actual = Integer (rule) + 1 ELSE Actual = Rule ENDIF DISPLAY r, Rule, Actual ENDFOR
INTEREST RATE ( % )
RULE OF 72
ACTUAL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
72 36 24 18 14.4 12 10.285 9 8 7.2 6.545 6 5.538 5.142 4.8 4.5 4.235 4 3.789 3.6
72 36 24 18 15 12 11 9 8 8 7 6 6 6 5 5 5 4 4 4