Commit 96f14817 by otsall

Replace task.c

parent c106c10f
Showing with 25 additions and 9 deletions
...@@ -95,17 +95,33 @@ void futurebalance(char array[USERS][DATAVAR][MAXLENGTH], int years, int user){ ...@@ -95,17 +95,33 @@ void futurebalance(char array[USERS][DATAVAR][MAXLENGTH], int years, int user){
} }
printf("your balance right now is %s\n", array[user][3]); printf("your balance right now is %s\n", array[user][3]);
currentbal = atof(array[user][3]); currentbal = atof(array[user][3]);
if(i == 1){ if (currentbal > 0){
for(j = 0; j < years; j++){ if(i == 1){
currentbal = 1.006 * 1.006 * currentbal; for(j = 0; j < years; j++){
balance[j] = currentbal; currentbal = 1.006 * 1.006 * currentbal;
printf("%d year(s) from now your balance will be %.2f\n", j + 1, balance[j]); balance[j] = currentbal;
printf("%d year(s) from now your balance will be %.2f\n", j + 1, balance[j]);
}
}else{
for(j = 0; j < years; j++){
currentbal = 1.005 * currentbal;
balance[j] = currentbal;
printf("%d year(s) from now your balance will be %.2f\n", j + 1, balance[j]);
}
} }
}else{ }else{
for(j = 0; j < years; j++){ if(i == 1){
currentbal = 1.005 * currentbal; for(j = 0; j < years; j++){
balance[j] = currentbal; currentbal = -1.079 * abs(currentbal);
printf("%d year(s) from now your balance will be %.2f\n", j + 1, balance[j]); balance[j] = currentbal;
printf("%d year(s) from now your balance will be %.2f\n", j + 1, balance[j]);
}
}else{
for(j = 0; j < years; j++){
currentbal = -1.083 * abs(currentbal);
balance[j] = currentbal;
printf("%d year(s) from now your balance will be %.2f\n", j + 1, balance[j]);
}
} }
} }
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment