Build a C++ application that will accept input from users for an initial investm
ID: 3849021 • Letter: B
Question
Build a C++ application that will accept input from users for an initial investment. Using an if... else if else chain, determine the total number of compounding periods and the appropriate interest rate based on their initial investment. Finally, display all of this information, and a calculated final investment value (using compound interest). Be sure to name all variables and constants properly as per the style guide You must include complete program documentation: Block comment at the top of your code with Application Author, Application Name, Date of Creation, and a detailed Description Single line comments describing each variable/constant Block comments calling attention to your input/processing/output sections Other single line comments as necessaryExplanation / Answer
/*
NAME-
ALL Other information
*/
// Headers files
#include <iostream> // for input output
#include <cmath> // for math functions
using namespace std; // using namespace standard
int main()
{
double initial_investment, Compound_interest; // variable for initial investment and compound interest, type double
double rate[5] = {6.0, 6.5, 7.0, 8.0, 5.0}; // interest rate differnt depends on investment value
int time = 1; // time duration
cout<<"Enter Initial Investment";
cin>>initial_investment; // takes value of initial investment from user
cout << "Initial Investment is "<<initial_investment<<endl;
cout <<"time rate interest total value"<<endl;
// time here is less or equal to 10
while(time<=10)
{
if(initial_investment <= 1000)//if value of investment less than or equal to 1000
{
Compound_interest = initial_investment * pow((1+rate[0]/100),time) - initial_investment;
}
else if (initial_investment <= 10000){
Compound_interest = initial_investment * pow((1+rate[1]/100),time) - initial_investment;
}
else if (initial_investment <= 100000){
Compound_interest = initial_investment * pow((1+rate[2]/100),time) - initial_investment;
}
else{
Compound_interest = initial_investment * pow((1+rate[3]/100),time) - initial_investment;
}
cout<<time<<" "<<rate[0]<<" "<<Compound_interest<<" "<<initial_investment+Compound_interest<<endl;
initial_investment+=Compound_interest;
time++;
}
cout<<"Final value "<<initial_investment<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.