Can someone tell me what these functions do? Do i enter a value in the ( ) like AcceptInput (4)?
Thanks,
John
AcceptInput()
EndBalance()
Adjustments()
FinalBalance()
Accumulators()
PrintStatement()
Can someone tell me what these functions do? Do i enter a value in the ( ) like AcceptInput (4)?
Thanks,
John
AcceptInput()
EndBalance()
Adjustments()
FinalBalance()
Accumulators()
PrintStatement()
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.
Away.
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 In addition, accounts with a negative balance do not receive 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 ( ) { //Print out the heading line 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
Replace what he does with the correspondiong function (meaning you write a new function)
would be in the AcceptInput() functionCode: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;
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
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;
}
ok so each funtion is part of the program just cut into sections?
like int main()
sorry if im way off
Thanks
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); { //Print out the heading line 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; }
Can anyone please tell me where im going wrong.
Thanks,
John
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.Code:int main ( ) int acceptinput(current_bank_balance,total_amount_depo sits,total_amount_checks_written); {
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
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 ( )
{
//Print out the heading line
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;
}
1) Use code tags.
2) You don't have an accept input function. You only have a unfinished prototype. See:
Either:int acceptinput (current_bank_balance,total_amount_deposits,total_
amount_checks_written)
int main ( )
{
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:
Quzah.Code:{ ...code here, enclosed in {} like so... }
Hope is the first step on the road to disappointment.
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 ( ) {
In the function header for acceptinput() you have to specify what type each parameter is. Eg:
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:int acceptinput(float current_bank_balance, float total_amount_deposits, float total_amount_checks_written) { . . . }
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; }
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials