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 Excercise 3a 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 Excercise 3b so that the main program also prompts the user for the interest rate and passses both the amount of money and the interest rate to the interest calculating method.

// Pseudocode PLD Chapter 9 #3 pg. 421

// Start

// Declarations

// num amount

// num newAmount

// num interestRate

// output "Please enter the dollar amount. "

// input amount

// output "Please enter the interest rate(e.g., nine percet should be entered as 9.0). "

// input interestRate

// newAmount = FutureValue(amount,interestRate)

// output "The new dollar amount is ", newAmount

// Stop

//

//

//

// num FutureValue(num initialAmount, num interestRate)

// Declarations

// num finalAmount

// finalAmount = (1 + interestRate/100) * initialAmount

// return finalAmount

Respuesta :

Answer:

see explaination

Explanation:

a)

amount = 5000

rate = 2

year = 1

interest = calculateInterest(amount, rate, year);

finalAmount = amount + interest

###### function ######

calculateInterest(amount, rate, year):

interest = (amount*rate*year)/100;

return interest

b)

amount <- enter amount

rate = 2

year = 1

interest = calculateInterest(amount, rate, year);

finalAmount = amount + interest

###### function ######

calculateInterest(amount, rate, year):

interest = (amount*rate*year)/100;

return interest

c)

#include <iostream>

using namespace std;

// function defination

double calculateInterest(double amount, double rate, int year);

int main(){

double amount, rate;

int year = 1;

cout<<"Enter amount: ";

cin>>amount;

cout<<"Enter rate: ";

cin>>rate;

// calling method

double interest = calculateInterest(amount, rate, year);

cout<<"Amount after 1 year: "<<(amount+interest)<<endl;

return 0;

}

// function calculation

double calculateInterest(double amount, double rate, int year){

return (amount*rate*year)/100.0;

}

In this exercise we have to use the knowledge in computational language in python to write the following code:

We have the code can be found in the attached image.

So in an easier way we have that the code is

a)amount = 5000

rate = 2

year = 1

interest = calculateInterest(amount, rate, year);

finalAmount = amount + interest

calculateInterest(amount, rate, year):

interest = (amount*rate*year)/100;

return interest

b)amount <- enter amount

rate = 2

year = 1

interest = calculateInterest(amount, rate, year);

finalAmount = amount + interest

calculateInterest(amount, rate, year):

interest = (amount*rate*year)/100;

return interest

c)#include <iostream>

using namespace std;

double calculateInterest(double amount, double rate, int year);

int main(){

double amount, rate;

int year = 1;

cout<<"Enter amount: ";

cin>>amount;

cout<<"Enter rate: ";

cin>>rate;

double interest = calculateInterest(amount, rate, year);

cout<<"Amount after 1 year: "<<(amount+interest)<<endl;

return 0;

}

double calculateInterest(double amount, double rate, int year){

return (amount*rate*year)/100.0;

}

See more about python at brainly.com/question/18502436

Ver imagen lhmarianateixeira
Ver imagen lhmarianateixeira
Ver imagen lhmarianateixeira