Page 1 of 1

## 3 Replies - 4312 Views - Last Post: 25 October 2009 - 06:53 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=134350&amp;s=a6c2ccef5f42c068a1c268651a986e35&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 R0423

Reputation: 0
• Posts: 2
• Joined: 25-October 09

Posted 25 October 2009 - 05:01 PM

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.

Is This A Good Question/Topic? 0

### #2 xPurplex

Reputation: 10
• Posts: 93
• Joined: 17-June 09

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 R0423

Reputation: 0
• Posts: 2
• Joined: 25-October 09

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 GenHornet18

Reputation: 36
• Posts: 629
• Joined: 19-October 09