c - Future Value calculator and Exponents -


I am trying to create a future value calculator and I do not have permission to use the power function. The formula for calculating future value is the value of the future = Prime * (1 + rate) ^ (the number of duration) I can not use ^ for exponents, so I tried to use the base and exponent concept, which gives the closest answer I expected but still is not correct. It gives me a price but it does not have the correct answer and it is too big if you need more information, please ask

Test Run:

Investment Calculator

Principal: 1000 Annual Rate: 0.06 Number of years: 5 Future value is $ 1338225577600000.000000

The expected result is $ 1338.23.

  contains # lt; Stdio.h & gt; Double Futurewell (double rule, double rate, int year); Int main () {Double principal; Double annual crack; Number number; Double results; Printf ("Investment Calculator \ n"); Printf ("===================== \ n"); Printf ("Principal:"); Scanf ("% Left", & amp; Principal); Printf ("Annual Rate:"); Scanf ("% Left", & amp; annualRate); Printf ("Number of years:"); Scanf ("% d", & amp; NUMYEARS); Results = Futurewell (principal, annual rate, number); Printf ("The future value is $% LF \ n", the result); Return 0; } Dual prediction (double rule, double rate, int year) {int i; Double value = (raj * (1 + rate)); Double result = 1; For (i = 0; i & lt; years; i ++) {Results * = value; } Return results;    

The task will work:

  double Future Val (double raj, double rate, int year) {int i; Double value = 1 + rate; Double result = 1; For (i = 0; i & lt; years; i ++) {Results * = value; } Result * = theory; Return result; }   

Since its formula to find the form

  prin * ((+ 1 + rate) ^ year)   

And what are you doing:

  (prin * (1 + rate)) ^   

This is the reason for the wrong output < Pre> printf ("The value of the future is $ .2lf \ n" If you want to display only 2 digits after the decimal, use it:

, the result) ; In the main method after the function call   



Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -