Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

C++ help

OpenStudy (anonymous):

#include <iostream>; #include <iomanip>; #include <string> using namespace std; int main() { int yearRate, payments; double loan, monthPay, paidBack, interest, rate; cout << setprecision(2) << fixed; //gets loan amount, cout << "Enter the loan amount => "; cin >> loan; //gets yearly interest rate cout <<"Enter the yearly interest rate as a percentage => "; cin >> yearRate; //gets number of payments cout << "Enter the number of payments "; cin >> payments; //This is where the formula goes //outputs the loan, yearRate, payments, monthPay, paidBack, and interest variables cout << "Loan Amount: $ " << loan; cout << "Yearly Interest Rate: $ " << yearRate; cout << "Number of Payments: $ " << payments; cout << "Monthly Payment: $ " << monthPay; cout << "Amount Paid Back: $ " << paidBack; cout << "Interest Rate: $ " << interest; //option to end program cin.ignore(); cout << "Press enter to end"; cin.get(); return 0; }

OpenStudy (anonymous):

Payment = (Rate * (1 + Rate)^N)/(((Rate + 1)^N) - 1)

OpenStudy (anonymous):

Payment is the monthPay variable. Rate is the rate variable. N is the payment variable. L is the loan variable.

OpenStudy (anonymous):

I need to turn the "//This is where the formula goes" section into a c++ formula that is the same as the formula i listed

OpenStudy (bibby):

ther is no ^ operator. There is a pow function in cmath

OpenStudy (anonymous):

i know, the formula i listed is not cmath, i need to convert it

OpenStudy (anonymous):

the only way that i can incorporate the exponents is by making another variable

OpenStudy (anonymous):

from what i can tell

OpenStudy (bibby):

what's wrong with rate * pow((1+rate),n) etc.

OpenStudy (anonymous):

\[Payment = \frac{Rate * (1 + Rate)^{N} }{ ((1 + Rate)^{N} - 1} * L\] this is how the original formula looks

OpenStudy (anonymous):

umm i don't know, does that work?

OpenStudy (anonymous):

btw there is a ) after the -1 i forgot to add

OpenStudy (anonymous):

thx for ur help, that does seem to work

OpenStudy (bibby):

\[Payment = \frac{Rate * pow((1 + Rate),N) }{ pow((1 + Rate),N) - 1} * L\] yep. no problem

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!