::SIGH:: Functions=Frustration

This is a discussion on ::SIGH:: Functions=Frustration within the C++ Programming forums, part of the General Programming Boards category; I can't get this acceptinput function to work for the life of me, what am I doing wrong, all Ii ...

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    22

    Angry ::SIGH:: Functions=Frustration

    I can't get this acceptinput function to work for the life of me, what am I doing wrong, all Ii get is error after error.

    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 (  )
    
    {
    
                //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
    
               
               
               
               
                acceptinput ();
    
               
               
               
               
                //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;
    
    }
    void acceptinput()
    {
    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;
    
                }

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    i dont know if this will fix your problem but being that this is the c++ forum ill suggest the following...

    use: #include <iostream>
    not: #include <iostream.h>

    add: using namespace std; // after include statments.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    22
    Thanks Salem, it worked here is my result. Tell me what you think.


    btw Salem, I PM'ed you, I don't know if you check them or not.

    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;
    
               
               
                void acceptinput()//Begin Accept Input Function
    {
    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;
    
                }//End Accept Input Function
    
    
    
    void EndBalance()    //Begin End Balance Function
    {
     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;
    
    }//End End Balance Function
    
    
    
    void finalbalance() //Begin Final Balance Function
    
    {
                final_balance = ending_balance - monthly_charges + dividends;
    
    }//End Final Balance Function
                
    
    
    
    void Accumulators()//Begin Accumulators Function
    
    {
    total_monthly_charges = total_monthly_charges + monthly_charges;
    total_dividends = total_dividends + dividends;
    
    }//End Accumulators Function
    
    void Printstatement()  //Begin Print Statement Function
    {
    
                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 Print Statement Function
    
    
    
    
    void printtotals() //Begin Print Totals Function
    {
     cout << "    Totals:\n";
    
                cout << "\t\tMonthly Charges: $" << total_monthly_charges << "\n";
    
                cout << "\t\tDividends:       $" << total_dividends;
    
    
    }// End Print Totals Function
    
    
    
    
    
    
    int main (  )
    
    {
    
                //Print out the heading line
    
                cout << "\t\t\t\t\t\tFirst Bank of Charlie Elings\n\n";
    
                
    
                //Start the loop
    
                for(loopcount=1; loopcount < 4; loopcount++)
    
                {
    
                // Bring the input information in               
               
               
                acceptinput ();        
                                   
                //compute           
                
                EndBalance();
               
               finalbalance();
                
                //accumulate totals
                
                Accumulators ();        
                
                //print a detail line
              
               Printstatement();
               
                }                                   //end loop            
               
                //Print Totals
    
               printtotals();
                
    
                return 0;
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why is this function not working? Sigh...
    By musique in forum C++ Programming
    Replies: 16
    Last Post: 05-03-2009, 04:54 PM
  2. Sigh, Brainfart. Controlling how += operator is used?
    By Zeusbwr in forum C# Programming
    Replies: 8
    Last Post: 11-09-2005, 08:11 PM
  3. Extreme hardware control...sigh...
    By jinx in forum C++ Programming
    Replies: 5
    Last Post: 04-29-2004, 01:40 PM
  4. sigh
    By Tyrael in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2001, 06:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21