I am tyring to write a simple program to displa yloan information. Here are my instructions:

The monthly payment on a loan may be calculated by the following formula

monthly payment=(monthlyrate*(1-monthlyrate)^time/(1+monthlyrate)^time-1)*loanamount

Use pow function in your formula

To raise a number to the power of another number you will have to use the pow function.

You will have to include the following header file

#include <cmath>

You will prompt the user for the following information:

Annual Rate: Note that you will have to take the user entry and divide it by 12 to get the monthly rate and then further divide by 100 to convert it to a percentage. (12 % annual interest would be 1% monthly interest.) You will be using the converted rate in your formula. The user entry is the annual rate but you will use the monthly rate in your formula

N is the number of payments

Loan amount

Calculate and displays a report similar to the following: (Sample data)

Loan Amount: $ 10000.00

Annual Interest Rate: 12

Number of Payments: 36

Monthly Payment: $ 332.14

Amount Paid Back $ 11957.15

Interest Paid: $ 1957.15

Validation:

Loan amount should be between $100 and $500,000

Interest rate should be between 1 % and 20%

Number of payments should be between 5 and 360 months

The report should be formatted and aligned according to the above

Here is my code so far:

```
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
double doublerate, rate, payment, paid, interest, annualrate,amount; // Declaring variables
int number;
paid=amount/number;
interest=amount*annualrate;
rate=annualrate/12;
doublerate=rate+1.0;
payment=((pow(doublerate, number)*rate)/pow (doublerate, number)-1)*amount;
cout << "Loan Interest Program"; // Program Name
cout << "\n\n\nPlease enter your annual rate\n"; //Asks for user input
cin >> annualrate; //Gets user info
do {
cout << "\nPlease enter the number of payments\n"; //Asks for user input
cin >> number; // Gets user info
do {
cout << "\nPlease enter loan amount\n"; //Asks for user input
cin >> amount; //Gets user info
do {
printf("\nLoan Amount: $%-7.2f", amount);
printf("\nAnnual Interest Rate: %-2.2f", annualrate);
cout << "%";
printf("\nNumber of Payments: %-2d", number);
printf ("\nMonthly Payment: $%-3.2f", payment);
printf("\nAmount Paid Back $%-6.2f"), paid;
printf ("\nInterest Paid: $%-6.2f", interest);
cout <<"\n\n";
} while (amount >100 && amount <500,000);
} while (number <360 && number >5);
}while (rate <20 && rate >1);
}
```

I know it's weird, but my instructor wants us to use C and C++, and wants us to use pow and a do/while loop.