A machine purchased for $28,000 is depreciated at a rate of $4000 a year for seven years. Write and run a C++ program that computes and displays a depreciation table for seven years. The table should have the form:
Answer:
In case of any query do comment. Please rate answer as well. Thanks
Code:
#include <stdio.h>
int main()
{
int cost =28000, depreciation =4000, accumulatedDepreciation =0;
printf("\t\t\tEND-OF-YEAR\tACCUMULATED\n");
printf("YEAR\tDEPRECIATION\t VALUE\tDEPRECIATION\n");
printf("----\t------------\t-----------\t------------\n");
//run the loop for 7 iterations
for (int i = 1; i <= 7; i++) {
//add depreciation to accumulatedDepreciation
accumulatedDepreciation += depreciation;
cost -= depreciation; //minus the cosgt to get end of year value
//%5d is used to right justify the output with 5 character on console,\t is used to provide a tab space
printf("%d\t %d\t\t %5d\t\t %5d\n",i,depreciation,cost,accumulatedDepreciation);
}
return 0;
}
============screen shot for indentation ======
You might also like to view...
What does ANSI stand for?
A. American National Standards Institute B. Alliance of National Standardizing Institutions C. American National Systems Integration D. Allied National Systems Inter development
Access is known as a(n) ________ system because it allows users to administer groups of data in tables and create relationships
Fill in the blank(s) with correct word
A web feed contains links to or information about updated or changed content on a website.
Answer the following statement true (T) or false (F)
The control string passed to scanf() typically consists of conversion control sequences only.
Answer the following statement true (T) or false (F)