A machine purchased for RM28,000 is depreciated at a rate of RM4,000 a year for 7 years.
Write and run a C++ program that computes and displays a depreciation table for 7 years.
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
int purchased_price = 28000;
int rate = 4000;
int year = 7;
cout << setw(7) << "YEAR" << setw(16) << "DERPRICIATION" << setw(20) << "END-OF-YEAR VALUE" << setw(27) << "ACCUMULATED DEPRICIATION\n";
cout << setw(7) << "____" << setw(16) << "_____________" << setw(20) << "_________________" << setw(27) << "________________________\n";
for (int i = 0; i < year; i++) {
cout << setw(7) << i + 1 << setw(16) << rate << setw(20) << purchased_price - rate * (i + 1) << setw(27) << rate * (i + 1) << endl;
}
}
Comments
Leave a comment