diff --git a/Project/.gitignore b/Project/.gitignore new file mode 100644 index 0000000..d3114e1 --- /dev/null +++ b/Project/.gitignore @@ -0,0 +1,3 @@ +/Project.depend +/bin +/obj diff --git a/Project/main.c b/Project/main.c index 022b16e..15d15ec 100644 --- a/Project/main.c +++ b/Project/main.c @@ -3,6 +3,46 @@ int main() { - printf("Hello world!\n"); + double A, C, p; + + printf("Enter the initial cost of the product: "); + scanf(" %lf", &A); + + printf("Enter the desired cost of the product: "); + scanf(" %lf", &C); + + while(A <= C) + { + + printf("The initial cost is already lower or equal to the desired one. \nEnter the desired one again: "); + scanf(" %lf", &C); + } + + printf("Enter the percentage reduction in the cost of the product for the year: "); + scanf(" %lf", &p); + + //printf("A = %lf \nC = %lf \np = %lf \n", A,C,p); + + for(int i = 1; i <= 10; i++) + { + A *= (1 - (p / i) / 100); + printf("A = %lf\n", A); + + if(A < C) + { + printf("The cost of the product dropped below the desired cost after %d years\n", i); + break; + } + } + + if(A > C) + { + printf("The cost of the product did not fall below the desired cost\n"); + } + + + printf("Press any key to exit...\n"); + getchar(); + getchar(); return 0; }