1. ## Future Value Functions

I am having a horrible time getting my functions to communicate with each other. Please if someone could assist, I am not looking for hand-outs but am a beginner banging my head on the wall and Ritchie's C book.

Description: This program calculates what a current amount will be worth in a future year based on yearly compounded interest earned.

Input: User enters starting amount, interest rate, number of years, and the starting year.

Output: Program calculates year 2019 balance, interest earned, and total percent gained.

Algorithm:
Code:

Code:
```    1. Print COP2220 line.
2. Prompt user for starting amount.
4. Prompt user for interest rate.
6. Prompt user for number of years.
8. Prompt user for starting year.
10. Validate input data.
11. Check data.
12. Print error messages.
13. If statement errors end program.
14. Do calculations.
-Calculate future year.
-Calculate future value.
-Calculate interest earned.
-Calculate total percent gained.
15. Print results.
16. Exit program.```

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <math.h>

//Function Declarations
float CollectUserInputs();

int main()
{
printf("COP2220-51014 Project 2: Andrew Ossi\n\n");
CollectUserInputs();

return 0;
}

//Statements
float CollectUserInputs()
{
float startamt;
float interestrate;
int years;
int startyear;

int error;

printf("\nEnter a Starting amount (dollars and cents): ");
scanf("%f", &startamt);
printf("Enter an Interest rate (ex. 2.5 for 2.5%):   ");
scanf("%f", &interestrate);
printf("Enter the Number of years (integer number):  ");
scanf("%d", &years);
printf("Enter the Starting year (four digits):       ");
scanf("%d", &startyear);
printf("\n");

//validate the user inputs. if there is any kind of error, exit the program, else continue.

error = 0;

if (startamt <= 0){
printf("Starting amount must be at least one cent.\n");
error = 1;
}

if (interestrate <=0){
printf("Interest rate must be at least .1%.\n");
error = 1;
}

if (years <=0){
printf("Number of years must be at least 1.\n");
error = 1;
}

if (startyear < 999 || startyear > 9999){
printf("Year must be four digits\n");
error = 1;
}

//if there are errors, end the program.
if (error == 1){
printf("Exiting\n");
return 0;
}
else if (error == 0){
return startamt;
return interestrate;
return years;
return startyear;
}
}//main

/*================================FY============================================
Calculate the Future Year from keyboard input and return it.
*/
void downFun (int startyear, int years);
{
//Local Definitions
int years;
int startyear;
int FY;

//Statements
*FY = startyear - years;
return 0;
}       downFun``` 2. Also posted here.

Jim 3. O_o

Dammit Jim, I'm a programmer, not an administrator.

Soma 4. Originally Posted by andyouf Code:
```    else if (error == 0){
return startamt;
return interestrate;
return years;
return startyear;
}```

<scottyvoice>
She's return'in fer all she's worth capt'n, she can no take anymore!
</scottyvoice> 5. Hint: You need to use pointers to have multiple values external to the function affected in the calling the function.
If pointers not yet covered, then struct command will likely be needed, instead.

Tim S. Popular pages Recent additions 