can someone help me to check any problems in this program...i cant run my program..
/* calculate depreciation using one of three different methods */
#include <stdlib.h>
#include <stdio.h>
#include<ctype.h>
void SL (void);
void DDB (void);
void SYD (void);
main()
{
int n, N, year, choice = 0;
float val, value, deprec, tag;
char answer1 = 'Y', answer2 = 'Y';
while(toupper(answer1) != 'N')
{
system("CLS");
if(toupper(answer2) != 'N')
{
printf("\nOriginal value: ");
scanf("%f", &value);
printf("Number of years: ");
scanf("%d", &N);
}
printf("\nMethod: (1-SL 2-DDB 3-SYD) ");
scanf("%d", &choice);
val = value;
n = N;
switch(choice)
{
case 1:SL();break;
case 2:DDB();break;
case 3:SYD();break;
default:puts("invalid entry");
}
printf("\n\nAnother calculation? [Y/N] ");
scanf("%1s", &answer1);
if(toupper(answer1) != 'N')
{
printf("Enter a new set of data? [Y/N] ");
scanf("%1s", &answer2);
}
}
system("pause");
}
void SL (void)
{ int n, N, year, choice = 0;
float val, value, deprec, tag;
char answer1 = 'Y', answer2 = 'Y';
printf("\nStraight Line Method\n\n");
deprec = val/n;
for (year = 1; year <= n; year++)
{
val -= deprec;
printf("\nEnd of year %2d ", year);
printf("\nDepreciation: %7.2f ", deprec);
printf("\nCurrent value:%8.2f\n", val);
}
}
void DDB(void)
{
int n, N, year, choice = 0;
float val, value, deprec, tag;
char answer1 = 'Y', answer2 = 'Y';
printf("\nDouble Declining Balance Method\n\n");
for (year = 1; year <= n; year++)
{
deprec = 2*val/n;
val = deprec;
printf("End of year %2d ", year);
printf("Depreciation: %7.2f ", deprec);
printf("Current value:%8.2f\n", val);
}
}
void SYD(void)
{ int n, N, year, choice = 0;
float val, value, deprec, tag;
char answer1 = 'Y', answer2 = 'Y';
printf("\nSum-of-the-Years\'-Digits method\n\n");
tag = val;
for (year = 1; year <= n; year++)
{
deprec = (n-year+1)*tag/(n*(n+1)/2);
val -= deprec;
printf("End of year %2d ", year);
printf("Depreciation: %7.2f ", deprec);
printf("Current value:%8.2f\n", val);
}
}
thank you...