- #1
Naldo6
- 102
- 0
My Homework is write a program to show the depreciation of an item each year during 10 years, for a porcentage given. The prgram shoul include:
1- Data entry validation
2-Calculate all the values for each year,and tehn of calculate all the values should show de results.
3-If the final value at the end of the year is less than the 72% of the original value of the original value of the item, should show "Valor Por debajo de lo deseado".
4- Use arrays.
I have done my program yet, but i don't know if i use the apropiate way with the arrays, because the program give me and corrupted variable on the valorfinal and depreciacionfinal variables, but if i ignore the error, in the screen it is showed what the professor wants... i only need to cheq if i use the arrays in the appropoate way to do this programs.
Here is my program:
# include <stdio.h>
# include <math.h>
void main()
{
const int size=10;
float valorfinal[size];
float depreciacionfinal[size];
int year;
float valor,valorinicial,porciento,depreciacion;
printf("\nPrograma Para Determinar Depreciacion De Un Equipo\n\n");
do{
printf("Entre Valor Del Equipo:\n$");
scanf("\n%f",&valor);
}while(!(valor>0));
do{
printf("\nEntre El Porciento De Depreciacion:\n");
scanf("\n%f",&porciento);
}while(!(porciento>=0));
valorinicial=valor;
for(year=1;year<=size;year++)
{
depreciacion=valor*porciento/100;
valor=valor-valor*porciento/100;
depreciacionfinal[year]=depreciacion;
valorfinal[size]=valor;
if(valor>=.72*valorinicial)
printf("\nAl Year %i La Depreciacion= $%.2f y Valor Nuevo= $%.2f\n\n",year,depreciacionfinal[year],valorfinal[year]);
else
{
printf("\nAl Year %i La Depreciacion= $%.2f y Valor Nuevo= $%.2f\n",year,depreciacionfinal[year],valorfinal[year]);
printf("\t Valor Por Debajo De Lo Deseado\n\n");
}
}
}
1- Data entry validation
2-Calculate all the values for each year,and tehn of calculate all the values should show de results.
3-If the final value at the end of the year is less than the 72% of the original value of the original value of the item, should show "Valor Por debajo de lo deseado".
4- Use arrays.
I have done my program yet, but i don't know if i use the apropiate way with the arrays, because the program give me and corrupted variable on the valorfinal and depreciacionfinal variables, but if i ignore the error, in the screen it is showed what the professor wants... i only need to cheq if i use the arrays in the appropoate way to do this programs.
Here is my program:
# include <stdio.h>
# include <math.h>
void main()
{
const int size=10;
float valorfinal[size];
float depreciacionfinal[size];
int year;
float valor,valorinicial,porciento,depreciacion;
printf("\nPrograma Para Determinar Depreciacion De Un Equipo\n\n");
do{
printf("Entre Valor Del Equipo:\n$");
scanf("\n%f",&valor);
}while(!(valor>0));
do{
printf("\nEntre El Porciento De Depreciacion:\n");
scanf("\n%f",&porciento);
}while(!(porciento>=0));
valorinicial=valor;
for(year=1;year<=size;year++)
{
depreciacion=valor*porciento/100;
valor=valor-valor*porciento/100;
depreciacionfinal[year]=depreciacion;
valorfinal[size]=valor;
if(valor>=.72*valorinicial)
printf("\nAl Year %i La Depreciacion= $%.2f y Valor Nuevo= $%.2f\n\n",year,depreciacionfinal[year],valorfinal[year]);
else
{
printf("\nAl Year %i La Depreciacion= $%.2f y Valor Nuevo= $%.2f\n",year,depreciacionfinal[year],valorfinal[year]);
printf("\t Valor Por Debajo De Lo Deseado\n\n");
}
}
}