Patrick B. answered 04/21/20
Math and computer tutor/teacher
#include <stdio.h>
int main()
{
int n=-1;
double amount=-1;
while (n<=0)
{
printf(" Input the number of years :>");
scanf("%d",&n);
}
while (amount<0)
{
printf(" Input the amount :>");
scanf("%lf",&amount);
}
double depreciation_factor = 2.0f/n;
int iLoop;
double flAmt = amount;
printf(" YEAR DEPRECIATION AMOUNT REMAINING AMOUNT \n");
for (iLoop=0; iLoop<n; iLoop++)
{
double depreciated_amount = flAmt * depreciation_factor;
flAmt -= depreciated_amount;
printf("%d %12.2lf %12.2lf \n",(iLoop+1),
depreciated_amount,
flAmt);
}
}