In: Computer Science
a.Create the logic for a program using pseudocode that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed.
b.Modify the program in Exercise 2a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method.
c.Modify the program in Exercise 2b 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 interest-calculating method.
Please give a Thumps up if you like the answer.
a.
Start
Declarations
num balance
num PRINCIPAL = 5000
num INTEREST_RATE = 2
balance =
calculateBalance(PRINCIPAL,INTEREST_RATE)
output "After one year the balance is $",
balance
Stop
num calculateBalance(num PRINCIPAL,num INTEREST_RATE)
Declarations
num balance
balance = PRINCIPAL * (1 + INTEREST_RATE/100)
return balance
b.
Start
Declarations
num balance
num PRINCIPAL
num INTEREST_RATE = 2
output "Please enter principal amount : $"
input PRINCIPAL
balance =
calculateBalance(PRINCIPAL,INTEREST_RATE)
output "After one year the balance is $",
balance
Stop
num calculateBalance(num PRINCIPAL,num INTEREST_RATE)
Declarations
num balance
balance = PRINCIPAL * (1 + INTEREST_RATE/100)
return balance
c.
Start
Declarations
num balance
num PRINCIPAL
num INTEREST_RATE
output "Please enter principal amount : $"
input PRINCIPAL
output "Please enter interest rate : %"
input INTEREST_RATE
balance =
calculateBalance(PRINCIPAL,INTEREST_RATE)
output "After one year the balance is $",
balance
Stop
num calculateBalance(num PRINCIPAL,num INTEREST_RATE)
Declarations
num balance
balance = PRINCIPAL * (1 + INTEREST_RATE/100)
return balance