But I need it to devide by 12, 36 and 120 months, so they aren't identical. How would you suggest I'd solve that?
You were right about the z variable. Thanks.
Is this what you had in mind?
Code:
#include <iostream>
#include <iomanip>
#pragma hdrstop
using namespace std;
void ball(int g, int i, double a)
{
cout << fixed << setprecision(2) << endl
<< "You'll pay a monthly rate of " << (i+a)/g << " credits" << endl
<< "You will have payed " << a+i << " credits in all" << endl;
}
//---------------------------------------------------------------------------
#pragma argsused
main()
{
const int i = 500;
int n = 0, y = 0, b = 0;
double r, a;
cout << "---------------------Banky-bank loans--------------------"
<< endl << "We offer loans at only 8.5, 9 or 10%, "
<< endl << "depending on how long the repayment period will be."
<< endl << "---------------------------------------------------------"
<< endl << "We charge a minor 500 credit administration fee."
<< endl << "---------------------------------------------------------";
while (b == 0)
{
cout << endl << endl << "Inset amount you want to borrow ";
cin >> a;
cout << endl << "Do you want the 1, 3 or 10 year repayment plan? ";
cin >> y;
b = 1;
if (y == 1)
{
r = 8.5;
while (n < y)
{
a += (a/100)*r;
n++;
}
ball(12, i, a);
}
else if (y == 3)
{
r = 9;
while (n < y)
{
a += (a/100)*r;
n++;
}
ball(36, i, a);
}
else if (y == 10)
{
r = 10;
while (n < y)
{
a += (a/100)*r;
n++;
}
ball(120, i, a);
}
else
{
cout << "Wrong input! " << endl;
b = 0;
}
}
cin >> b;
}