-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractice question on investment .txt
91 lines (54 loc) · 1.8 KB
/
practice question on investment .txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
question
Create the logic for a program that calculates and displays the amount of money you would
have if you invested R5 000 at 2 percent interest for one year. Create a separate method
to do the calculation and return the result to be displayed.
start
Declarations
num investment = 5000
num intrest = 0.2
//call CalculateMoney(investment, intrest)
CalculateMoney(investment, intrest)
output " the results are" + total
stop
CalculateMoney(investment, intrest)
Declarations
num total
total = investment + (investment * intrest)
return total
question
Modify the program in (a) above so that the main program prompts the user for the amount
of money and passes it to the interest-calculating method.
start
Declarations
num input
num intrest = 0.2
//call IntrestCalculating( input, intrest )
IntrestCalculating( input, intrest )
output " your total is " + total
stop
//call method
IntrestCalculating( input, intrest )
Declarations
num total
total = input + (input * intrest)
return total
question
Modify the program in (b) above so that the main program also prompts the user for the
interest rate and passes both the amount of money and the interest rate to the interestcalculating method.
start
Declarations
num investment
num intrest
output " enter your investment "
investment = Convert.ToInt32(ReadLine)
output " enter your interest "
intrest = Convert.ToInt32(ReadLine)
//call method
IntrestCalculating( investment, intrest )
output " your total is " total
stop
IntrestCalculating( investment, intrest )
Declarations
num total
total = investment + (investment * intrest)
return total