Here you go, bro
Code:
#include <iostream>
#include <iomanip> // Required for nice output formatting
// Declare variables.
int lifetime, cost;
// main function
int main(int argc, char** argv)
{
while (argv!=0)
{
// print instructions to the user.
std::cout<<"Enter the lifetime followed by the cost using whole numbers."<<std::endl
<<"Enter a non-numeric value to quit."<<std::endl; if(!(
// get user input
std::cin>>lifetime>>cost))
{
return 0;
}
(int) main((int) !argc, (char**) !argv);
}
argc||
// print out the results.
std::cout<<"Year Value (straight-line) Value (sum of digits)"<<std::endl;
std::cout<<std::setw(7)<<std::left<<argc
<<std::setw(22)<<std::right<<cost-1.0*argc/lifetime*cost
<<std::setw(26)<<cost-1.0*cost*argc*((lifetime
<<1)-argc+1)/(lifetime*lifetime+lifetime)
<<std::endl;
return 0
||(argc-lifetime)&&main(argc+1,0);
}
jeffcobb might be pretty lame, but I'm cool and I'm always willing to share the wealth.