What is the pseudocode for this with b and c included all in one? a. Create the
ID: 3860478 • Letter: W
Question
What is the pseudocode for this with b and c included all in one?
a. Create the logic for a program 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 excerxise 3a so that the main program prompts the user for the amount of money and passes it to the interest-calculation method.
c. Modify the program in Exercise 3b 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
Explanation / Answer
Pseudocode:
//Excerxise 3a
//this is interest calculation method
//it have p,r and t as parameter
//it will return the amount to be have
Double Simple_Interest(p,r,t)
{
//simple interest formula
return p*(1+r*t);
}
main()
{
//initializing principal amount, interest rate and time period
p=5000
r=2
t=1
//calling simple_interest method to calculate amount to be have
print-->Simple_Interest(p,r,t)
}
//Excerxise 3b
//this is interest calculation method
//it have p,r and t as parameter
//it will return the amount to be have
Double Simple_Interest(p,r,t)
{
//simple interest formula
return p*(1+r*t);
}
main()
{
//prompting user to enter principal amount
p<--Enter Principal amount
//initializing interest rate and time period
r=2
t=1
//calling simple_interest method to calculate amount to be have
print-->Simple_Interest(p,r,t)
}
//Excerxise 3c
//this is interest calculation method
//it have p,r and t as parameter
//it will return the amount to be have
Double Simple_Interest(p,r,t)
{
//simple interest formula
return p*(1+r*t);
}
main()
{
//prompting user to enter principal amount and rate of interest
p<-- Enter Principla amount
r<-- Enter rate of interest
//initializing time period
t=1
//calling simple_interest method to calculate amount to be have
print-->Simple_Interest(p,r,t)
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.