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.
//Correct
#include <iostream>
using namespace std;
int main()
{
int value = 28000;
cout << "Initial cost: RM" << value << endl;
for(int i = 1; i<=7; i++)
{
value -= 4000;
cout << "Cost after " << i << " years of use: RM " << value << endl;
}
return 0;
}
Comments
Leave a comment