What's wrong with this code?
I need some help. What's wrong with the code below?
Code:
const int i = 500;
int y, n = 0, z = 0;
double r, a;
cout << "Inset amount you want to borrow ";
cin >> a;
cout << "Do you want the 1, 3 or 10 year repayment plan? ";
cin >> y;
if (y = 1)
{
y = 1;
r = 8.5;
}
else if (y = 3)
{
y = 3;
r = 9;
}
else if (y = 10)
{
y = 10;
r = 10;
}
else
{
cout << "wrong input!" << endl;
y = 0;
//how do I make it jump back up to the first cin?
}
while (n < y)
{
a += a/100*r;
z += a;
cout << "You'll pay a monthly rate of " << (a + i)/12 << " credits" << endl
<< "You will have payed " << z + i << " credits in all";
n++;
}
And is there a way I can make the else statement jump back to the first cin in the code?
PS: I'm a total n00b, so bare with me.