Friday, March 26, 2010

Stock Commission: This program also processes amount of commission (2%) from the amount paid for the stock alone. This program then adds amount paid for the stock alone and amount of commission to process total amount paid by Kathryn.


// Programming: Stock Commission
// Programming Environment: Bloodshed
// Date/Time: 1/22/2010  7:31:02 PM
//---------------------------------------------------------------------------
// This program has constant value of 600 shares and a price of $21.77 per share.
// Stock broker's commission is 2%.
// This program multiplies the number of share and price per share to get the
// amount paid for the stock alone.
// This program also processes amount of commission (2%) from the amount paid
// for the stock alone.
// This program then adds amount paid for the stock alone and amount of
// commission to process total amount paid by Kathryn.
// -------------------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
//---------------------------------------------------------------------------
// Named Constants
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Function Prototypes
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main (void)
{
    cout.setf (ios::fixed, ios::floatfield);
    cout.setf (ios::showpoint);
    cout.precision (2);
  
    // Variable Assignments and Initialization.
    int shares = 600;
    double price = 21.77;
    double commission = 2;
  
    double amount_stock;
    double amount_commission;
    double total_amount;
  
    // Information for the user: Kathryn bought 600 shares of stock at a
    // price of $21.77.
    cout << endl << "Since, Kathryn Bought 600 Shares of Stock at a Price of $21.77,";
    
    // Calculate and display amount paid for stock alone.
    amount_stock = shares * price; // Arithmetic Operators.
    cout << endl << "\a\n The amount paid for the stock alone, without the commission: " << "$" << amount_stock;
  
    // Information for the user: Commission for the transaction is 2%.
    cout << endl << "\n\nSince, commission for the stock broker is 2%,";
  
    // Calculate and display the amount of commission only.
    amount_commission = amount_stock * commission / 100; // Arithmetic Operators.  
    cout << endl << "\a\n The amount of commission for stock brokers: " << "$" << amount_commission;
  
    // Information for the user: Total Investment.
    cout << endl << "\n\nFinally, calculating total investment made on shares,";
  
    // Calculate and display the total amount paid by Kathryn.
    total_amount = amount_stock + amount_commission; // Arithmetic Operators.      
    cout << endl << "\a\n Total amount paid for the stock and the commission by Kathryn: " << "$" << total_amount;
        
    cout << endl << endl << endl << "Press Any Key to Continue...";
    getch (); // Holds the screen, so that, we can see the result.
    return 0;
}
//---------------------------------------------------------------------------
// Function Definitions follow.
//---------------------------------------------------------------------------

Advertisement: 

Contact us for Software Development, AI, and SEO Marketing - I Code Mind LLC

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.