Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a method \"invest\" to help customer to find the earnings by opening a sa

ID: 3581960 • Letter: D

Question

Design a method "invest" to help customer to find the earnings by opening a saving account. The method "invest" should take three parameters, as starting balance, annual interest rate, and years. Then this method will give back how much earned after that many of years. The equation is earning = balance * (1 + rate)^years. Write a complete program to accept values of starting balance, annual interest rate, and years from keyboard, then use this method to find the earning and then display the earning.

Explanation / Answer

#include <iostream>
#include <cmath>
using namespace std;

double invest(double balance,double rate,int years)
{
   double earning = balance *pow((1+rate),years); //compute earning
   return earning;
}
int main()
{
   double balance,rate;
   int years;
   cout<<"Enter the starting balance "; //input starting balance,rate of interest and number of years
   cin>>balance;
   cout<<" Enter the rate of interest";
   cin>>rate;
   cout<<" Enter the years";
   cin>>years;
   cout<<" Earning : $"<<invest(balance,rate,years);
   return 0;
}

output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote