#include <iomanip>
#include <iostream>
using namespace std;
#include <cmath>
int main( )
{
// output my name and objective and program information
cout << "Objective: calculate how much money to save every month for number of years before retirement and how much money would you have when you retire.\n " ;
cout << "Programmer: Paxcelli Flores\n " ;
cout << "Editor(s) used: Notepad\n " ;
cout << "Compiler(s) used: VC++ 2010 Express\n " ;
cout << "File: " << __FILE__ << endl;
cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
//variables
int deposit = 100 ;
double interestRate = 0.075 ;
int years = 10 ;
int time = 120 ;
double amountSaved = deposit * ( ( pow ( 1 + interestRate) , time ) - 1 ) / interestRate) ;
//calculations
interestRate = interestRate / 12
time = years * 12
amountSaved = deposit * ( ( pow ( 1 + interestRate) , time ) - 1 ) / interestRate)
//output calculated amount saved
cout << "In " << years << "years at " << interestRate << "% " ;
cout << deposit << "deposited per month will grow to $ " ;
cout .setf ( ios:: fixed | ios:: showpoint ) ;
cout << setprecision( 2 ) << amountSaved << "." << endl;
return 0 ;
return 0 ;
}
I2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2luY2x1ZGUgPGNtYXRoPgoKaW50IG1haW4oKQp7CgkKICAvLyBvdXRwdXQgbXkgbmFtZSBhbmQgb2JqZWN0aXZlIGFuZCBwcm9ncmFtIGluZm9ybWF0aW9uCiAgY291dCA8PCAiT2JqZWN0aXZlOiBjYWxjdWxhdGUgaG93IG11Y2ggbW9uZXkgdG8gc2F2ZSBldmVyeSBtb250aCBmb3IgbnVtYmVyIG9mIHllYXJzIGJlZm9yZSByZXRpcmVtZW50IGFuZCBob3cgbXVjaCBtb25leSB3b3VsZCB5b3UgaGF2ZSB3aGVuIHlvdSByZXRpcmUuXG4iOyAKICBjb3V0IDw8ICJQcm9ncmFtbWVyOiBQYXhjZWxsaSBGbG9yZXNcbiI7IAogIGNvdXQgPDwgIkVkaXRvcihzKSB1c2VkOiBOb3RlcGFkXG4iOy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 'int main()':
prog.cpp:22:56: error: no matching function for call to 'pow(double)'
double amountSaved = deposit * ((pow(1 + interestRate), time) - 1) / interestRate);
^
prog.cpp:22:56: note: candidates are:
In file included from /usr/include/features.h:374:0,
from /usr/include/i386-linux-gnu/c++/4.9/bits/os_defines.h:39,
from /usr/include/i386-linux-gnu/c++/4.9/bits/c++config.h:430,
from /usr/include/c++/4.9/iomanip:38,
from prog.cpp:1:
/usr/include/i386-linux-gnu/bits/mathcalls.h:153:1: note: double pow(double, double)
__MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
^
/usr/include/i386-linux-gnu/bits/mathcalls.h:153:1: note: candidate expects 2 arguments, 1 provided
In file included from prog.cpp:4:0:
/usr/include/c++/4.9/cmath:434:5: note: template<class _Tp, class _Up> typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::pow(_Tp, _Up)
pow(_Tp __x, _Up __y)
^
/usr/include/c++/4.9/cmath:434:5: note: template argument deduction/substitution failed:
prog.cpp:22:56: note: candidate expects 2 arguments, 1 provided
double amountSaved = deposit * ((pow(1 + interestRate), time) - 1) / interestRate);
^
In file included from prog.cpp:4:0:
/usr/include/c++/4.9/cmath:426:3: note: long double std::pow(long double, int)
pow(long double __x, int __n)
^
/usr/include/c++/4.9/cmath:426:3: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.9/cmath:422:3: note: float std::pow(float, int)
pow(float __x, int __n)
^
/usr/include/c++/4.9/cmath:422:3: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.9/cmath:418:3: note: double std::pow(double, int)
pow(double __x, int __i)
^
/usr/include/c++/4.9/cmath:418:3: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.9/cmath:411:3: note: long double std::pow(long double, long double)
pow(long double __x, long double __y)
^
/usr/include/c++/4.9/cmath:411:3: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/4.9/cmath:407:3: note: float std::pow(float, float)
pow(float __x, float __y)
^
/usr/include/c++/4.9/cmath:407:3: note: candidate expects 2 arguments, 1 provided
prog.cpp:27:3: error: expected ';' before 'time'
time = years * 12
^
stdout