Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ The profit from the sale of a stock can be calculated as follows: Profit =((

ID: 3595314 • Letter: C

Question

C++

The profit from the sale of a stock can be calculated as follows: Profit =((NSXSP)-SC ) . (( NS X PP ) + PC ) where NS is the number of shares, SP is the sale price per share, SC is the sale commission paid, PP is the purchase price per share, and PC is the purchase commission paid. If the calculation yields a positive value, then the sale of the stock resulted in a profit.If the calculation yields a negative number, then the sale resulted in a loss. Write a function called stock_profit that accepts as arguments the number of shares, the purchase price per share, the purchase commission paid, the sale price per share, and the sale commission paid. The function should return the profit (or loss) from the sale of stock. Use the stock profit function that you wrote above in a program that calculates the total profit or loss from the sale of multiple stocks. The program should ask the user for the number of stock sales and the necessary data for each stock sale. It should accumulate the profit or loss for each stock sale and then display the total. Save the file as stockprofits.cpp, upload the file, and submit the file to Blackboard.

Explanation / Answer

here is the code. If you find any difficulty to understand any part of the code, please let me know in the comment section. I will always here to help you. #include using namespace std; /* the function which calcutate the profit or loss of one stock sale*/ double stock_profit(int ns,double pp,double pc,double sp,double sc) { return ((ns*sp)-sc)-((ns*pp)-pc); } int main() { int n; // Ask user to enter the number of stock sales coutn; int ns; double pp,pc,sp,sc,total=0; for(int i=1;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote