I'm doing a program that calculates the monthly payments on a car and i just need to know how to use the "^" (power operator) I wrote the whole program already but i just need to know how to use the power operator in the following equation:

monthlyPayments = (monthlyInterest * (purchasePrice-downPayment)) * (((1+monthlyInterest)^loanTerm) / (((1+monthlyInterest)^loanTerm)-1));

I've tried to use the POW() function but it doesn't work for this. and if it does please tell me. I'm at my wits end trying to figure this problem out.

# MULTIPLYING WITH EXPONENTS IN C++... PLEASE HELP!

## DON'T KNOW HOW TO USE "^" OPERATOR IN C++

Page 1 of 1## 3 Replies - 3864 Views - Last Post: 25 October 2009 - 06:53 PM

### #1

# MULTIPLYING WITH EXPONENTS IN C++... PLEASE HELP!

Posted 25 October 2009 - 05:01 PM

##
**Replies To:** MULTIPLYING WITH EXPONENTS IN C++... PLEASE HELP!

### #2

## Re: MULTIPLYING WITH EXPONENTS IN C++... PLEASE HELP!

Posted 25 October 2009 - 05:08 PM

use the pow() function found in the math.h header file. If you would rather, you can also easily write your own function to work with exponents.

### #3

## Re: MULTIPLYING WITH EXPONENTS IN C++... PLEASE HELP!

Posted 25 October 2009 - 05:13 PM

xPurplex, on 25 Oct, 2009 - 04:08 PM, said:

use the pow() function found in the math.h header file. If you would rather, you can also easily write your own function to work with exponents.

i tried using the POW function already but i don't know how to do it if i don't have declared variables. all i have so far

is :

#include <iostream> #include <iomanip> using namespace std; int main() { //Variable Declarations float purchasePrice; //recorded in dollars float downPayment; //recorded in dollars float monthlyInterest; //recorded as a percent float loanTerm; //recorded in months float monthlyPayments; //in dollars cout << fixed << showpoint; cout << "To determine the monthly payment of your new vehicle" << endl << endl; cout << "Please enter the purchase price of the vehicle: " <<endl; cout << "$"; cin >> purchasePrice; cout << "Please enter the down payment: " << endl; cout << "$"; cin >> downPayment; cout << "Please enter the monthly interest rate: " << endl; cout << "% "; cin >> monthlyInterest; cout << "Please enter the term of the loan in months: " << endl; cin >> loanTerm; cout << endl << endl; monthlyPayments = (monthlyInterest * (purchasePrice-downPayment)) * (((1+monthlyInterest)*loanTerm) / (((1+monthlyInterest)*loanTerm)-1)); cout << "The monthly payment of your vehicle will be: " << endl; cout << setprecision(2) << "$" << monthlyPayments << endl; cout << endl << endl; cout << "The interest on the vehicle over the entire loan period will be:" << endl; cout << "$" << (purchasePrice*monthlyInterest)*loanTerm << endl; return 0; }

xPurplex, on 25 Oct, 2009 - 04:08 PM, said:

use the pow() function found in the math.h header file. If you would rather, you can also easily write your own function to work with exponents.

i'm not exactly sure what you mean by write my own function to work with exponents. can you give me an example please?

### #4

## Re: MULTIPLYING WITH EXPONENTS IN C++... PLEASE HELP!

Posted 25 October 2009 - 06:53 PM

problem with why your code doesn't work with pow() (i think anyway) is that your closing the function with one of your brackets before your done with it. So the smartest thing to do would be to just add the +1 and -1 before you put it into this entire calculation

Page 1 of 1