#include <iostream>
#include <cstdlib>
#include <math.h>
usingnamespace std;
int main(int argc, char *argv())
{
float pv, fv, r=0;
int n=0;
char answer = 0;
int mainloop = 1;
int firstloop = 1;
while(firstloop> 0){
cout <<"Welcome. "<<endl;
cout <<"If you wish to use this program please enter Y for yes."<<endl;
cout <<"If you wish to exit type E for exit:";
cin>>answer;
if (answer == 'e'|| answer == 'E')
{
cout<<"Good bye"<<endl;
mainloop -- ;
firstloop -- ;
}
elseif (answer == 'y'|| answer == 'Y'){
firstloop --;
}
else
{
cout<<"Your answer is not correct.. Try again."<<endl;
}
}
while(mainloop> 0)
{
system("CLS");
cout<<"Enter the cost value FU:"<<endl;
cin>>fv;
cout<<endl;
cout<<"Enter the rates for example type in 50. That would represent 50%"<<endl;
cout<<":";
cin>>r;
cout<<"Enter the number of years:";
cin>>n;
r/100;
for(n;n>0;n-- ) {
pv = pow(fv/(1+r),n);
cout<<pv <<endl;
}
system("pause");
}
return 0;
}
It's not coming out right! what am I doing wrong here
The For loop is suppose to count down from 4,3,2,1 and as it does the ^n is suppose to change with that
#include <iostream>
#include <cstdlib>
#include <math.h>
usingnamespace std;
int main(int argc, char *argv())
{
float pv=0, fv=0, r=0, vp;
int n=0;
char answer = 0;
int mainloop = 1;
int firstloop = 1;
while(firstloop> 0){
cout <<"Welcome. "<<endl;
cout <<"If you wish to use this program please enter Y for yes."<<endl;
cout <<"If you wish to exit type E for exit:";
cin>>answer;
if (answer == 'e'|| answer == 'E')
{
cout<<"Good bye"<<endl;
mainloop -- ;
firstloop -- ;
}
elseif (answer == 'y'|| answer == 'Y'){
firstloop --;
}
else
{
cout<<"Your answer is not correct.. Try again."<<endl;
}
}
while(mainloop> 0)
{
system("CLS");
cout<<"Enter the cost value FV:"<<endl;
cout<<":";
cin>>fv;
cout<<endl;
cout<<"Enter the rate value as a whole number. "<<endl;
cout<<":";
cin>>r;
cout<<"Enter the number of years:";
cin>>n;
r=r/100;
for(n;n>0;n-- ) {
pv=pow((1.0+r),n);
vp = (fv/pv);
cout<<vp <<endl;
}
system("pause");
}
return 0;
}
If you enter 250.00 as your dollar value, and 5 as your rates, number of years being 4
205.675 will appear as one of the answers along with th