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

COULD YOU WRITE IT IN PROGRAM dev C++ AND ECXCUTE, WIRTE EXPLANATION and comment

ID: 3566250 • Letter: C

Question

COULD YOU WRITE IT IN PROGRAM dev C++ AND ECXCUTE, WIRTE EXPLANATION and comments IN EACH STEP SO I CAN UNDERSTAND IT,

THANK YOU IN ADVANCE

A person who is about to retire has X dollars in the bank and expects to live for N years.

If savings earn interest at I %, the person's annual retirement income can be calculated using the formula below:

where i = I / 100

Write a program that repeatedly reads in values for X, N, and I until -1 -1 -1 is entered. (Note that all three values are doubles, not ints.) For each set of values entered your program should either:

i) output an error message (if the input values are unreasonable: see next paragraph) or

ii) compute and output the annual retirement income.

The value of X must be greater than or equal to zero, N must be greater than or equal to 5, and I must be between 0% (exclusive) and 10% (inclusive).

When -1 -1 -1 is entered your program should output:

i) the average annual income

ii) the greatest annual income and the corresponding values for X, N, and I. In the event of a tie either set of values may be output.

COULD YOU WRITE IT IN PROGRAM dev C++ AND ECXCUTE, WIRTE EXPLANATION and comments IN EACH STEP SO I CAN UNDERSTAND IT, THANK YOU IN ADVANCE A person who is about to retire has X dollars in the bank and expects to live for N years. If savings earn interest at I %, the person's annual retirement income can be calculated using the formula below: income=X(frac{i(1+i)^{N-1}}{(1+i)^{N }-1}) where i = I / 100 Write a program that repeatedly reads in values for X, N, and I until -1 -1 -1 is entered. (Note that all three values are doubles, not ints.) For each set of values entered your program should either: i) output an error message (if the input values are unreasonable: see next paragraph) or ii) compute and output the annual retirement income. The value of X must be greater than or equal to zero, N must be greater than or equal to 5, and I must be between 0% (exclusive) and 10% (inclusive). When -1 -1 -1 is entered your program should output: i) the average annual income ii) the greatest annual income and the corresponding values for X, N, and I. In the event of a tie either set of values may be output.

Explanation / Answer

#include <iostream>
#include <math.h>
#include<stdio.h>
using namespace std;

int main()
{
int k=0;
double x,n,I;
double income=0;
cout<<"enter x n and i values "<<endl;
cin>>x;
cin>>n;
cin>>I;
int l=0;
double d[5];
double i=I/100;
while(x!=-1&&n!=-1&&I!=-1)
{
if(x>=0&&n>=5&&I>0&&I<=10){
income=x*(pow (1+i,n-1)/(pow(i+1,n)-1));
d[k]=income;
k++;
cout<<"income is "<<income<<endl;}
else{
l++;
cout<<"error in input criteria..."<<endl;
//system.exit(0);
}
cout<<"enter x n and i values "<<endl;
cin>>x;
cin>>n;
cin>>I;
}
if(l!=0)
return 0;

else {
double avg=0;
int t=0;
int t1=0;
for(t=0;t<k;t++)
{
avg=avg+d[t];
}
avg=avg/k;
for(t=0;t<k;t++)
{
for(t1=0;t1<k-1;t1++)
{
if(d[t1]>d[t1+1])
{
double m=d[t1];
d[t1]=d[t1+1];
d[t1+1]=m;
}
}
}
cout<<"average is :"<<avg<<endl;
cout<<"Highest income is :"<<d[k-1]<<endl;
cout<<"program exited!"<<endl;
return 0;
}
}

o/p:

1)

2)

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