#include <string>
#include <iostream>
using namespace std;
int main()
{
int loanAmount[10];
int numMonths[10];
string keepGoing;
int counter = 0;
do
{
cout << "Please enter a loan amount: ";
cin >> loanAmount[counter];
cout << "Please enter the number of months: ";
cin >> numMonths[counter];
counter++;
cout << endl << "Do you want to continue (yes or no)? ";
cin >> keepGoing;
}while ((keepGoing == "yes") || (keepGoing == "YES"));
cout << endl << "*************************" << endl;
cout << "There are " << counter << " loans" << endl;
for (int x = 0; x < counter; x++)
{
cout << "Loan " << x << " For $" << loanAmount[x] << " for " << numMonths[x]<< " months ";
cout << "has a payment of $" << (double)loanAmount[x]/(double)numMonths[x] << " per month." << endl;
}
cout << "TOTAL MONTHLY PAYMENT: $" << loanAmount[counter] << endl;
}
Hello, I am having trouble summing up the monthly payment for the loan amounts the user has entered. Also, whenever it runs it says loan 1 is loan 0 and loan 2 is loan 1, etc...Any ideas on how I can fix this to have an output like this?
"
Please enter a loan amount: 1000
Please enter the number of months: 10
Continue (yes/no)? yes
Please enter a loan amount: 999
Please enter the number of months: 30
Continue (yes/no)? yes
Please enter a loan amount: 1234
Please enter the number of months: 5
Continue (yes/no)? no
************************* <<- YES PRINT THESE ASTERISKS
There are 3 loans.
Loan 1 for $1000 for 10 months has a payment of $100 per month
Loan 2 for $999 for 30 months has a payment of $33.3 per month
Loan 1 for $1234 for 5 months has a payment of $246.8 per month
TOTAL MONTHLY PAYMENT: $380.1"
Thanks for any help.