1. Functions

Can someone tell me what these functions do? Do i enter a value in the ( ) like AcceptInput (4)?

Thanks,
John

AcceptInput()
EndBalance()
FinalBalance()
Accumulators()
PrintStatement()

2. We can't tell you what the functions do without the code in which they were defined (look closer at the program). Those aren't standard functions like cout.

3. This is my assignment, I do not understand what he is saying modify with funtions. The program works fine already, what does he mean?

Thanks Alot

Code:
```You will be given an existing program to modify by using functions.

The existing program will produce a consolidated bank statement for 3 customers. The program computes the net balance for each customer and totals at the end of program execution.

Inputs: The user will enter their current bank balance, the total amount of deposits, and the total amount of checks written.

Calculations:  Ending Balance = current bank balance + deposits – amount of

checks written

Monthly Charges = \$8.00  if the ending balance is \$500 or over

\$25.00 if the ending balance is 0 to less than

\$500

\$8.00 + \$25.00 if the ending balance is less

than 0

Dividends =   2% if balance is below \$500

3.5% if balance is \$500 or over

Final Balance = Ending Balance – Monthly charges + dividends

Totals = accumulated totals of monthly charges and dividends

Existing Program without Functions (you modify this program):

Important – some of the lines in the program are on two lines that is because of the wrap around  feature of the word processor. When you enter them into the computer they are on one line.

#include <iostream.h>

#include <iomanip.h>

float current_bank_balance, total_amount_checks_written;

float total_amount_deposits;

float ending_balance, monthly_charges, dividends, final_balance;

float total_monthly_charges = 0, total_dividends = 0;

int loopcount;

int main (  )

{

cout << "\t\t\t\t\t\tFirst Bank of YourName\n\n";

//Start the loop

for(loopcount=1; loopcount < 4; loopcount++)

{

// Bring the input information in

cout << "Enter Beginning Balance:  ";

cin >> current_bank_balance;

cout << "Enter total amount of deposits: ";

cin >> total_amount_deposits;

cout << "Enter total amount of checks: ";

cin >> total_amount_checks_written;

//compute

ending_balance = current_bank_balance + total_amount_deposits - total_amount_checks_written;

if(ending_balance < 0)

{

monthly_charges = 33;

dividends = 0;

}

if(ending_balance >= 0 && ending_balance < 500)

monthly_charges = 25;

if(ending_balance >= 500)

monthly_charges = 8;

if(ending_balance >= 0 && ending_balance <= 500)

dividends = 0.02 * ending_balance;

if(ending_balance > 500)

dividends = 0.035 * ending_balance;

final_balance = ending_balance - monthly_charges + dividends;

//accumulate totals

total_monthly_charges = total_monthly_charges + monthly_charges;

total_dividends = total_dividends + dividends;

//print a detail line

cout.setf(ios::fixed);

cout << setprecision(2) << "\n\t\t\t\t\tBeginning Balance \$ " << current_bank_balance << "\n";

cout << "\t\t\t\t\tDeposits          + " << total_amount_deposits << "\n";

cout << "\t\t\t\t\tLess Checks       - " << total_amount_checks_written << "\n";

cout << "\t\t\t\t\tEnding Balance    \$ " << ending_balance << "\n";

cout << "\t\t\t\t\tMonthly Charges   - " << monthly_charges << "\n";

cout << "\t\t\t\t\tDividend          + " << dividends << "\n";

cout << "\t\t\t\t\tFinal Balance     \$ " << final_balance << "\n\n";

}                                   //end loop

//Print Totals

cout << "    Totals:\n";

cout << "\t\tMonthly Charges: \$" << total_monthly_charges << "\n";

cout << "\t\tDividends:       \$" << total_dividends;

return 0;

}

Output: Output should be similar to the bank statement below. Numeric values should be aligned and to two decimal places. User input is indicated in bold.

First Bank of YourName

Enter Beginning Balance:  541.32

Enter total amount of deposits: 784.50

Enter total amount of checks: 526.22

Beginning Balance \$ 541.32

Deposits                 + 784.50

Less Checks           - 526.22

Ending Balance      \$ 799.60

Monthly Charges    - 8.00

Dividend                 + 27.99

Final Balance         \$ 819.59

Enter Beginning Balance:  541.32

Enter total amount of deposits: 784.50

Enter total amount of checks: 526.22

Beginning Balance \$ 541.32

Deposits                 + 784.50

Less Checks           - 526.22

Ending Balance      \$ 799.60

Monthly Charges     - 8.00

Dividend                  + 27.99

Final Balance          \$ 819.59

Enter Beginning Balance:  541.32

Enter total amount of deposits: 784.50

Enter total amount of checks: 526.22

Beginning Balance \$ 541.32

Deposits                 + 784.50

Less Checks           - 526.22

Ending Balance      \$ 799.60

Monthly Charges    - 8.00

Dividend                 + 27.99

Final Balance         \$ 819.59

Totals:

Monthly Charges: \$24.00

Dividends:            \$83.96

Important this sample output was done using the same customer 3 times. You should make up two new customers for your run in addition to the customer used. These customers should check out different aspects of the program.

********************************************************************************

Remember the Totals print after 3rd customer

Processing: Include a loop within your code. The functions listed below, as a minimum, should be implemented. Each function should have a header. Comment where appropriate. Save the file as BANK.CPP

Function                                 Description

AcceptInput()                         Prompt the user for the required values and store in

variables

EndBalance()                        Calculate the ending balance

Adjustments()                        Calculate the appropriate monthly charges and

dividends

FinalBalance()                                   Calculate the final balance

Accumulators()                      Accumulate monthly charges and dividends

PrintStatement()                    Print the bank statement for each customer.

This does not include the Totals print which will be done after the third customer.

Attach BANK.CPP to your email with a subject of Bank```

4. Replace what he does with the correspondiong function (meaning you write a new function)
Code:
```cout << "Enter Beginning Balance:  ";

cin >> current_bank_balance;

cout << "Enter total amount of deposits: ";

cin >> total_amount_deposits;

cout << "Enter total amount of checks: ";

cin >> total_amount_checks_written;```
would be in the AcceptInput() function

5. So i just clear all the cin and cout and type acceptinput() ?
I'm lost do i have to seta fuction for each function command. For example

acceptinput()=
{
cout<<"how many checks did you write:";
cin<<checks;
}

6. ok so each funtion is part of the program just cut into sections?

like int main()

sorry if im way off

Thanks

7. Hello again, I entered the function but it wont recognize it, likely i did it wrong. I was trying to enter an acceptinput function. This is what I have.

Thanks,
John

Code:
```#include <iostream.h>

#include <iomanip.h>

float current_bank_balance, total_amount_checks_written;

float total_amount_deposits;

float ending_balance, monthly_charges, dividends, final_balance;

float total_monthly_charges = 0, total_dividends = 0;

int loopcount;

int main (  )
int acceptinput(current_bank_balance,total_amount_deposits,total_amount_checks_written);
{

cout << "\t\t\t\t\t\tFirst Bank of YourName\n\n";

//Start the loop

for(loopcount=1; loopcount < 4; loopcount++)

{

// Bring the input information in

{
cout << "Enter Beginning Balance:  ";

cin >> current_bank_balance;

cout << "Enter total amount of deposits: ";

cin >> total_amount_deposits;

cout << "Enter total amount of checks: ";

cin >> total_amount_checks_written;

}
//compute

ending_balance = current_bank_balance + total_amount_deposits - total_amount_checks_written;

if(ending_balance < 0)

{

monthly_charges = 33;

dividends = 0;

}

if(ending_balance >= 0 && ending_balance < 500)

monthly_charges = 25;

if(ending_balance >= 500)

monthly_charges = 8;

if(ending_balance >= 0 && ending_balance <= 500)

dividends = 0.02 * ending_balance;

if(ending_balance > 500)

dividends = 0.035 * ending_balance;

final_balance = ending_balance - monthly_charges + dividends;

//accumulate totals

total_monthly_charges = total_monthly_charges + monthly_charges;

total_dividends = total_dividends + dividends;

//print a detail line

cout.setf(ios::fixed);

cout << setprecision(2) << "\n\t\t\t\t\tBeginning Balance \$ " << current_bank_balance << "\n";

cout << "\t\t\t\t\tDeposits          + " << total_amount_deposits << "\n";

cout << "\t\t\t\t\tLess Checks       - " << total_amount_checks_written << "\n";

cout << "\t\t\t\t\tEnding Balance    \$ " << ending_balance << "\n";

cout << "\t\t\t\t\tMonthly Charges   - " << monthly_charges << "\n";

cout << "\t\t\t\t\tDividend          + " << dividends << "\n";

cout << "\t\t\t\t\tFinal Balance     \$ " << final_balance << "\n\n";

}                                   //end loop

//Print Totals

cout << "    Totals:\n";

cout << "\t\tMonthly Charges: \$" << total_monthly_charges << "\n";

cout << "\t\tDividends:       \$" << total_dividends;

return 0;

}```

8. Can anyone please tell me where im going wrong.

Thanks,
John

9. Code:
```int main (  )
int  acceptinput(current_bank_balance,total_amount_depo
sits,total_amount_checks_written);
{```
Move the prototype above 'int main'. Its in no-mans land right now. Also, I don't know if that line-break is intentional, but it needs to go.

10. I still can't get it to not error. this is what i have it keeps erroring on my accept input.

John

#include <iostream.h>

#include <iomanip.h>

float current_bank_balance, total_amount_checks_written;

float total_amount_deposits;

float ending_balance, monthly_charges, dividends, final_balance;

float total_monthly_charges = 0, total_dividends = 0;

int loopcount;

int acceptinput (current_bank_balance,total_amount_deposits,total_ amount_checks_written)

int main ( )
{

cout << "\t\t\t\t\t\tFirst Bank of YourName\n\n";

//Start the loop

for(loopcount=1; loopcount < 4; loopcount++)

{

// Bring the input information in

{
cout << "Enter Beginning Balance: ";

cin >> current_bank_balance;

cout << "Enter total amount of deposits: ";

cin >> total_amount_deposits;

cout << "Enter total amount of checks: ";

cin >> total_amount_checks_written;

}

11. 1) Use code tags.
2) You don't have an accept input function. You only have a unfinished prototype. See:
int acceptinput (current_bank_balance,total_amount_deposits,total_
amount_checks_written)

int main ( )
{
Either:
a) End that line with a semi-colon, and then write the function some where else.
b) Write the function there. To do so, you must follow that line by:
Code:
```{
...code here, enclosed in {} like so...
}```
Quzah.

12. This is what I have and it keeps erroring on the comma rite after current_bank_balance in acceptinput function. How can i get this funtion to work correctly?

Thanks,
John

Code:
```#include <iostream.h>

#include <iomanip.h>

float current_bank_balance, total_amount_checks_written;

float total_amount_deposits;

float ending_balance, monthly_charges, dividends, final_balance;

float total_monthly_charges = 0, total_dividends = 0;

int loopcount;

int acceptinput(current_bank_balance, total_amount_deposits, total_amount_checks_written)
{
cout << "Enter Beginning Balance:  ";

cin >> current_bank_balance;

cout << "Enter total amount of deposits: ";

cin >> total_amount_deposits;

cout << "Enter total amount of checks: ";

cin >> total_amount_checks_written;

}
int main (  )
{```

13. In the function header for acceptinput() you have to specify what type each parameter is. Eg:

Code:
```int acceptinput(float current_bank_balance, float total_amount_deposits, float total_amount_checks_written)
{
.
.
.
}```
Also, you'll need to change the way you use the variables. The thing is, you've declared all of the variables globally. That means they are available in every function you make. By specifying those variables in a function header you are attempting to make new variables with those same names. The compiler shouldn't let you do that. You'll have to decide to either pass variables by pointer or by reference, or simply use global variables. For now, I suggest global variables. Eg:

Code:
```#include <blah>

float total_stuff,more_stuff;
float even_more_stuff;

int acceptinput()
{
cin >> total_stuff;
cin >> more_stuff;
cin >> even_more_stuff;
return 0;
}

int main()
{
acceptinput();
...
..
.
return 0;
}```