fork download
  1. #include <iomanip>
  2. #include <iostream>
  3. using namespace std;
  4. #include <cmath>
  5.  
  6. int main()
  7. {
  8.  
  9. // output my name and objective and program information
  10. 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";
  11. cout << "Programmer: Paxcelli Flores\n";
  12. cout << "Editor(s) used: Notepad\n";
  13. cout << "Compiler(s) used: VC++ 2010 Express\n";
  14. cout << "File: " << __FILE__ << endl;
  15. cout << "Complied: " << __DATE__ << " at " << __TIME__ << endl << endl;
  16.  
  17. //variables
  18. int deposit = 100;
  19. double interestRate = 0.075;
  20. int years = 10;
  21. int time = 120;
  22. double amountSaved = deposit * ((pow(1 + interestRate), time) - 1) / interestRate);
  23.  
  24.  
  25. //calculations
  26. interestRate = interestRate / 12
  27. time = years * 12
  28. amountSaved = deposit * ((pow(1 + interestRate), time) - 1) / interestRate)
  29.  
  30. //output calculated amount saved
  31.  
  32. cout << "In " << years << "years at " << interestRate << "% ";
  33. cout << deposit << "deposited per month will grow to $ ";
  34. cout.setf(ios::fixed|ios::showpoint);
  35. cout << setprecision(2) << amountSaved << "." << endl;
  36.  
  37. return 0;
  38. return 0;
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function '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
Standard output is empty