Programming C++

Please help I am getting a conversion error in my program i have spend the whole of weekend and I can seem to figure out what the exact problem is.
the error seem to be in this lines bellow:

cin>>s;
if(s =="Y" || s =="y" || s == "yes")
{
flag = false;
}

}






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


int main(int argc, char** argv) {

int year;
bool flag = true;
while (flag) {
// get the value of year
cout<<"\n------------------------------------------\n";
cout<<"The number must be in the range of 1 to 70\n"
"Enter the number of year. :";
cin>>year;
if (year < 1 || year >70) {
// do nothing
}
else
{
flag = false;
}
}

flag = true;
float initial_value;
while (flag) {
// get the value of year
cout<<"\n------------------------------------------\n";
cout<<"The number must be non negative \n"
"Enter an initial value of the IRA :";
cin>>initial_value;
if (initial_value <0) {
// do nothing
}
else
{
flag = false;
}
}


float annual_amount;

flag = true;
while (flag) {
// get the value of year
cout<<"\n------------------------------------------\n";
cout<<"The number must be between 0 and $2500 \n"
"Enter the annual amount added to the IRA :$";
cin>>annual_amount;
if (annual_amount < 0 || annual_amount > 2500) {
// do nothing
}
else
{
flag = false;
}
}




flag = true;
float average_interest_rate;
string s = "n";
while (flag) {
// get the value of year
cout<<"\n------------------------------------------\n";
cout<<"Enter the average interest rate : ";
cin>>average_interest_rate;
if (average_interest_rate < 0) {
cout<<" Do you really expect to lose money every year because the value is negative .\n ";

}
else
{
if (average_interest_rate > 10) {
cout<<"Do you really thinks you can earn more than an average of 10% per year. \n ";
}
else
{
break;
}
}
cin>>s;
if(s =="Y" || s =="y" || s == "yes")
{
flag = false;
}

}


// calculate

float value = initial_value;
float rate = average_interest_rate/100;

cout<<"\n------------------------------------------\n";
cout<<"\nthe initial amount is "<<initial_value<<
"\nthe interest rate is "<<average_interest_rate<<
"%\nthe yearly addition is $"<<annual_amount<<
"\nthe number of years is "<<year<<"\n";

cout<<"\n------------------------------------------\n";
cout<<"\tyear\tvalue\n";
for (int i = 0; i < year; i++) {
value = value * (1 + rate) + annual_amount;
if ((i+1)%5 == 0) {
cout<<"\t"<<i+1<<"\t$"<<value<<"\n";
}
}
cout<<"The final value is : $"<<value<<"\n";
system("pause");

return 0;
}

1
2
3
4
5
#include <cstdlib>
#include <iostream>
#include <string> // This little booger here!
#include <math.h>
using namespace std;


Compiled on mine.
Edit: use code tags when you post it makes it easier for others to read they will help you more.
They are to your right when you respond under format top left, they look like <>
Last edited on
Oh I appreciate for your help the program is working now. I will use your advise of using code tags in the future posts.
Topic archived. No new replies allowed.