Having some issues with return value function and void functions.... particularly how to call (invoke).
objective: Make a program to have user enter deposit to both Savings and Checking accounts.
make a function with getSavingsBalance(deposite, interestRate, year)
Add a new value-return function for Checking account balance similar to Savings getCheckingBalance(deposite, interestRate, year)
Create a void function displayBalance(year, checkingBalance, savingBalance) to display the savings and checking account balance
You call a function by writing the name of the function, and then in brackets, the names of the parameters you wish to pass.
Let's do an example, with your function getCheckings.
Name of the function: getCheckings
Names of parameters to pass it: Let's say there is an int that exists, called beans.
So you would call the function like this:
Calling a function is a really basic thing. Definitely make sure you understand how to call a function; it's the name of the function, and then in brackets, the names of the variables you want to pass it, separated by comma. You must put those parameters in the right order.
Here is how to capture the returned value of that function:
someVariable = getCheckings(beans);
This stores the returned value from the function in the variable someVariable. So if the function returned, for example, 17, someVariable now has the value 17.
function for Checking account balance similar to SavingsgetCheckingBalance(deposite, interestRate, year)
Your getCheckings looks ... different.
Overall, what are these Checking and Saving? How do they differ?
Every account has interestRate, money that has been put in, and time it has been there.
What is fundamentally different between checks and saves?
The checkings += amount; does the same as checkings = checkings + amount;
The checkings was initialized with 0.0. Lets substitute the value into the statement: checkings = 0.0 + amount;
That should be about the same as checkings = amount;
Function then returns the checkings, which is equal to the amount.
One more substitution and then discard the unused variable: