Answer to Question #279493 in C++ for Alunsina

Question #279493

A machine purchased for P28,000 is depreciated at a rate of P4,000 a year for seven years. Draw a flowchart, write an algorithm and design a C++ program that computes and displays in a suitably sized list box a depreciation table for seven years. The table should have the following form:

Year

Depreciation

End-of-year value

Accumulated depreciation

1

4000

24000

4000

2

4000

20000

8000

3

4000

16000

12000

4

4000

12000

16000

5

4000

8000

20000

6

4000

4000

24000

7

4000

0

28000


1
Expert's answer
2021-12-14T09:30:46-0500
An algorithm  
Declare Real endYearValue
Declare Real depricatedRate
Declare Real accumulatedDepreciation
Declare Integer year


Set endYearValue = 28000
Set depricatedRate = 4000
Set accumulatedDepreciation = 0
Display "Year Depreciation End-of-year value Accumulated depreciation"
For year = 1 To 7
    Set endYearValue = endYearValue - depricatedRate
    Set accumulatedDepreciation = accumulatedDepreciation + depricatedRate
    Display year, "  ", depricatedRate, "  ", endYearValue, "  ", accumulatedDepreciation
End For




a C++ program

#include <iostream>
#include <iomanip>
using namespace std;




int main() {
    double endYearValue = 28000;
    double depricatedRate = 4000;
	double accumulatedDepreciation=0;




	cout<<"Year\tDepreciation\tEnd-of-year value\tAccumulated depreciation\n";
    cout <<fixed<< setprecision(2) ;
    for (int year=1; year <= 7; year++) {
        endYearValue -= depricatedRate;
		accumulatedDepreciation+=depricatedRate;
		cout  << year << "\t" <<depricatedRate<<setw(17)<< endYearValue<<setw(25)<<accumulatedDepreciation<< endl;
    }
	cin>>accumulatedDepreciation;
}



flowchart







Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog