# Help me out understand what I need to do please?

• 10-11-2005
seal
Help me out understand what I need to do please?
Here is the directions I have for my assignment

A student of the FAU Computer Science program graduates on their birthday at age X.
They are immediately hired by a company at salary Y (after taxes). They save Z percent of their income each year in a cookie jar on top of their refrigerator. Each year, on their birthday, they add the contents of the cookie jar to their tax-deferred investment plan which returns W percent compounded annually (on their birthday).

Write a C program which reads in the values of X, Y, Z and W from the keyboard and displays on the screen how much money they have in their investment plan on every birthday up to age 95. (When they retire to a life of yachting, race car driving, and attending those wild FAU alumni parties!). At the bottom of this, display on the screen what their age is when they become a millionaire (only count money in the investment plan, not the cookie jar).

I'm not really understanding the W one... anyone care to help? =/
• 10-11-2005
itsme86
Well an investment plan is pretty lame if it doesn't make any interest. W is going to tell you how much interest they're earning each year. If W is 5% and they have \$100 in their investment plan, then they gain \$5 each year from interest. What about it don't you understand? Do you just not know what interest is?
• 10-11-2005
seal
english is not my 1st language, so I got a little bit confused I guess...
• 10-11-2005
seal
I dont even know what kinda coding i'm supposed to write for this project :(

all I know is I gotta use loops, and at least 3 userdefined functions
• 10-11-2005
cwr
Describe what you want the program to do. Express it in a set of statements that could be translated into code, then convert it to code. Example:

Get age from user into X
Get salary from user into Y.
Get percent saved from user into Z.
Get compound interet percent from user into W.

Code:

```Loop from age = X to age = 95 {     Calculate how many years passed since the current time.     Apply compound interest formula based on number of years     Output the result }```
For information on interest, see http://en.wikipedia.org/wiki/Interest

Make a good attempt at coding this, and we'll help.
• 10-11-2005
seal
This is what I have so far...
Code:

```#include <stdio.h> int main () {     int agex;     double salaryy;     double savez;     double investw; // we get all the information we need here printf ("Enter your birthday\n"); scanf ("%f", &agex); printf ("Enter your salary\n"); scanf ("%lf", &salaryy); printf ("What percentage of your salary would you like to put in the cookie jar?\n"); scanf ("%lf", &savez); printf ("What is the interest rate?\n"); scanf ("%lf", &investw); { for( int age = agex; age != 96; age++ ) } }```
I keep getting an error on the for line saying
Quote:

20 'for' loop initial declaration used outside C99 mode
• 10-11-2005
Dave_Sinkula
It seems likely your earlier training used the bastard C/C++ language instead of one or the other. Try
Code:

`  int age, agex;`
along with
Code:

`  for ( age = agex; age != 96; age++ )`
And don't forget to use the proper format sepcifier:
Code:

`  scanf ("%d", &agex);`
And add this before the end of main, just for "Be Kind to the OS Day":
Code:

`  return 0;`
• 10-11-2005
seal
Quote:

Originally Posted by Dave_Sinkula
It seems likely your earlier training used the bastard C/C++ language instead of one or the other. Try
Code:

`  int age, agex;`
along with
Code:

`  for ( age = agex; age != 96; age++ )`
And don't forget to use the proper format sepcifier:
Code:

`  scanf ("%d", &agex);`
And add this before the end of main, just for "Be Kind to the OS Day":
Code:

`  return 0;`

yeah I hadnt added the return 0 cuz i'm trying to figure out this program lol, but i will put that in the end, and thx for cataching the "%d"!

I've changed to code to this

Code:

```#include <stdio.h> int main () {     int agex, age;     double salaryy;     double savez;     double investw; // we get all the information we need here printf ("Enter your birthday\n"); scanf ("%d", &agex); printf ("Enter your salary\n"); scanf ("%lf", &salaryy); printf ("What percentage of your salary would you like to put in the cookie jar?\n"); scanf ("%lf", &savez); printf ("What is the interest rate?\n"); scanf ("%lf", &investw); for( age = agex; age != 96; age++ ) { //what now? lol I guess i'll figure that part out when I wake up }    return 0; }```
teacher also told us to put in user defined functions, but I dont know where to put these (I need to look over and figure out how to write'm anyways)

Quote:

Your program should have at least three (3) user defined functions with the following prototypes:
void Instruction( );
/* this function displays instructions on how the program works
void DisplayMillionAge( int a);
/*this function takes the age when the user will become a millionaire. */
int GetStartAge( );
/*This function prompts the student for their current age and returns it*/
• 10-11-2005
Dave_Sinkula
Protoypes go before the function is called to tell the compiler whether you're using them correctly. The function definitions, then, can go later even after they are used (as long as the "signature" matches and things are done properly).