The equation I need to use is:

payment = [(rate * (1 + rate)^number payments ) / ((1 + rate)^number of payments -1)] * loan

Also, the value of rate in the above equation is (interest/12)/100. So 12% annual interest would be 1% monthly interest.

Would anyone please steer me in the right direction!

All help is greatly appreciated!

heres my code:

#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main(){ //Declaration of variables as integers and doubles. int option, loan, payamount, convertedrate, interestrate, days,speed, hours, distance; double interest, numberpayments, initialdollars; //Display the menu options. cout<<"1) Interest"<<endl; cout<<"2) Compound"<<endl; cout<<"3) Distance"<<endl; cout<<"4) Quit"<<endl; cout<<"\n"; cout<<"Choose an option: "; cin>>option; //Result of the users input: switch (option){ //When the user enters a 1,program prompts them to input information //to calculate interest. case 1: //Program asks user for a loan amount. cout<<"\n"; cout<<"Enter the amount of the loan: $"; cin>>loan; cout<<"\n"; //If the input is not in the range of 100-20,000, the program will //continue asking until the user inputs a number of the correct range. if (loan < 100 || loan > 20000) do{ cout<<"Please enter a loan amount between $100 and $20,000"; cout<<"\n"<<endl; cout<<"Enter the amount of the loan: $"; cin>>loan; cout<<"\n"; }while (loan < 100 || loan > 20000); //Program asks user for an annual interest rate. cout<<"Enter the Annual Interest Rate: $"; cin>>interest; cout<<"\n"; //If the input is not in the range of 1-20, the program will //continue asking until the user inputs a number of the correct range. if (interest < 1 || interest > 20) do{ cout<<"Please enter an Annual Interest Rate between 1 and 20"; cout<<"\n"<<endl; cout<<"Enter the Annual Interest Rate: $"; cin>>interest; cout<<"\n"; }while (interest < 1 || interest > 20); //Program asks user for a number of payments. cout<<"Enter the number of payments: "; cin>>numberpayments; cout<<"\n"; //If the input is not in the range of 100-20,000, the program will //continue asking until the user inputs a number of the correct range. if (numberpayments < 5 || numberpayments > 360) do{ cout<<"Please enter a number of payments between 5 and 360 months"; cout<<"\n"<<endl; cout<<"Enter the number of payments: "; cin>>numberpayments; cout<<"\n"; }while (numberpayments < 5 || numberpayments > 360); //Calculation for the loan. //NEED HELP WITH FORMULA****************** // convertedrate=(interest/12)/100 // payamount= ((convertedrate * pow((1 + convertedrate), numberpayments))/ (pow((1 + convertedrate), numberpayments) -1))*loan; //Displays the user input and calculation for inputs in a readable format. // printf("") //When the user enters a 2, program prompts them to input information //to calculate coumpound. case 2: //Program asks user for the amount in dollars. cout<<"Initial amount in dollars?"; cin>>initialdollars; //If the input is not in the range of 10-10,000, the program will //continue asking until the user inputs a number of the correct range. if (initialdollars < 10 || initialdollars > 10000) do{ cout<<"\n"; cout<<"Dollar amount should be between 10 and 10000."<<endl; cout<<"Try again!"; cin>>initialdollars; cout<<"\n"; }while (initialdollars < 10 || initialdollars > 10000); cout<<"\n"; //Program asks user for an interest rate in percentage cout<<"Interest rate in percentage?"; cin>>interestrate; //If the input is not in the range of 1-22, the program will //continue asking until the user inputs a number of the correct range. if (interestrate < 1 || interestrate > 22) do{ cout<<"\n"; cout<<"Interest rate be between 1 and 22."<<endl; cout<<"Try again!"; cin>>interestrate; cout<<"\n"; }while (interestrate < 1 || interestrate > 22); cout<<"\n"; //Program asks user for a number of days. cout<<"Number of days?"; cin>>days; //If the input is not in the range of 2-30, the program will //continue asking until the user inputs a number of the correct range. if (days < 2 || days > 30) do{ cout<<"\n"; cout<<"Interest rate be between 2 and 30."<<endl; cout<<"Try again!"; cin>>days; cout<<"\n"; }while (days < 2 || days > 30); cout<<"\n"; //Display of user input and calculation of inputs in a readable format. //LOOP FOR COMPOUND GOES HERE //NEED HELP //When the user enters a 3,program prompts them to input information //to calculate speed. case 3: //Program asks user for the speed. cout<<"What is the speed of the vehicle in mph? "; cin>>speed; //If the input is not in the range of 20-200, the program will //continue asking until the user inputs a number of the correct range. if (speed < 20 || speed > 200) do{ cout<<"\n"; cout<<"Wrong range. Try again "; cin>>speed; }while (speed < 20 || speed > 200); cout<<"\n"; //Program asks user for the number of hours. cout<<"How many hours has it traveled? "; cin>>hours; //If the input is less than 3, the program will //continue asking until the user inputs a greater than or equal to 3. if (hours < 3) do{ cout<<"\n"; cout<<"Come on... A real number this time. Try again. "; cin>>hours; }while (hours < 3); cout<<"\n"; distance=speed * hours; //LOOP TO OUTPUT THE INFO //NEED HELP //When the user enters a 4,program closes. case 4: cout<<"goodbye"; return 0; default: cout<<"wrong entry: try again"<<endl; cout<<"\n"; cout<<"1) Interest"<<endl; cout<<"2) Compound"<<endl; cout<<"3) Distance"<<endl; cout<<"4) QUIT"<<endl; cout<<"\n"; cout<<"Choose an option: "; cin>>option; } system("pause>nul");//does this pause the screen? //return 0; // check if you need to pause the screen in specs! }

This post has been edited by **Skydiver**: 12 February 2014 - 12:33 AM

Reason for edit:: Put code in code tags. Learn to do this yourself.