# Help with program pleeeasseee!!!

This is a discussion on Help with program pleeeasseee!!! within the C++ Programming forums, part of the General Programming Boards category; calculation depreciation costs enter a cost (dollars) for an asset along with its expected life (years) then the resulting depreciation ...

1. ## Help with program pleeeasseee!!!

calculation depreciation costs

enter a cost (dollars) for an asset along with its expected life (years)

then the resulting depreciation amount and book value (remaining value after depreciation) should be calculated and displayed for each year of the assest's lifetime - using both methods

methods:
straight-line method: calculates depreciation amount (cost / expected_life) that is equal amounts spread out over the lifetime of the item. each year the book value is subtracted by the depreciation amount

sum-of-digits: uses the sum of the years' digits and varying proportions to determine each year's depreciation amount.

would like to be able to enter varying cost and expected life pairs before deciding to end the program

must use sentinel control repeition when entering values for the cost of the assest and its expected life until the user wishes to end the program

nested repetition must be used for the counter-controlled loop dependent on the expected life

2. So what have you coded so far? We won't write the code for you but we will help you with what you have written..

3. Here you go, bro

Code:
#include <iostream>
#include <iomanip> // Required for nice output formatting

// Declare variables.

// 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
{
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::endl;
return 0
}
jeffcobb might be pretty lame, but I'm cool and I'm always willing to share the wealth.

4. Originally Posted by NeonBlack
Here you go, bro

Code:
#include <iostream>
#include <iomanip> // Required for nice output formatting

// Declare variables.

// 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
{
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::endl;
return 0
}
jeffcobb might be pretty lame, but I'm cool and I'm always willing to share the wealth.
Geez and I thought there was some rule about doing homework around here and encouraging folks to at least try coding a solution...when I first got here I did what Neon did (whipping out tested ready-made solutions when people just posted the problem w/o even trying to solve it) and got my knuckles slapped for it...

Some days you just can't win...

5. There's a difference between writing simple off the shelf answers that could be handed in without further effort from the OP, and the kind of obfuscated "delights" that Neon posted.

Whilst it may functionally solve the OPs problem, it's not an answer they can immediately use - bad bad Neon

The OP might try to hand it in, but it would be a dead giveaway that they didn't write it, and they would have some serious 'explaining' to do.

6. Technically, NeonBlack's shared wealth is not even a valid C++ program.

7. Salem, I like that. I think I might call them "delights" from now on too.

laserlight, thanks for pointing that out. That's something I didn't know, have never needed to know, and gcc accepts it without -pedantic. You can never have too much limitedly useful knowledge.