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

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

Page 1 of 1

3 Replies - 2076 Views - Last Post: 25 October 2009 - 06:53 PM Rate Topic: -----

#1 R0423  Icon User is offline

  • New D.I.C Head

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

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

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
  • +

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

#2 xPurplex  Icon User is offline

  • D.I.C Head
  • member icon

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

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.
Was This Post Helpful? 0
  • +
  • -

#3 R0423  Icon User is offline

  • New D.I.C Head

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

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

Posted 25 October 2009 - 05:13 PM

View PostxPurplex, 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;
}



View PostxPurplex, 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?
Was This Post Helpful? 0
  • +
  • -

#4 GenHornet18  Icon User is offline

  • Darken the Radar

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

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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1