fork download
  1. //Diego Martinez CSC5 Chapter 2, P.84, #17
  2.  
  3. /*******************************************************************************
  4. * Verifying Stock Commission
  5. * ______________________________________________________________________________
  6. * This program calculates the total amount Kathryn paid for her stock including
  7. * the commision she has to pay to her stock broker.
  8. *
  9. * Computation is based on the Formula:
  10. * Stock Amount = Shares * Price per Share
  11. * Commission = Stock Amount * Commission Rate
  12. * Total Amount = Stock Amount + Commission
  13. *_______________________________________________________________________________
  14. * INPUT
  15. * shares : Total Number of shares
  16. * pricePerShare : Cost of each share
  17. * commissionRate : Broker commission rate
  18. *
  19. * OUTPUT
  20. * stockAmount : Amount paid for the stock alone
  21. * commission : Amount of the strock brocker's commission
  22. * totalAmount : Total amount paid including commission
  23. *******************************************************************************/
  24.  
  25. #include <iostream>
  26. using namespace std;
  27.  
  28. int main()
  29. {
  30.  
  31. //Given Values
  32. int shares = 600;
  33. double pricePerShare = 21.77;
  34. double commissionRate = 0.02;
  35.  
  36. //Calculations
  37. double stockAmount = shares * pricePerShare;
  38. double commission = stockAmount * commissionRate;
  39. double totalAmount = stockAmount + commission;
  40.  
  41. //Output
  42. cout << "Amount paid for the stock alone: $" << stockAmount << endl;
  43. cout << "Amount of the commisson: $" << commission << endl;
  44. cout << "Total amount paid (stock + commission): $" << totalAmount <<endl;
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Amount paid for the stock alone: $13062
Amount of the commisson: $261.24
Total amount paid (stock + commission): $13323.2