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

Must be done in visual studios Write a Stock Commission program. If Kathryn boug

ID: 3793111 • Letter: M

Question

Must be done in visual studios

Write a Stock Commission program. If Kathryn bought 600 shares of stock at the price of 21.77 per share. She must pay her stock broker a 2 percent commission for the transaction. Write a program that calculates and displays the following. Allow input for the cost of the stock per share and the number of shares purchased.

The amount paid for the stock alone (without the commission).

The amount of the commission

The total amount paid (for the stock plus the commission)

Instead of 600 shares allow the use to input the number of shares and the price per share of the stock.

Formatting Output: Be sure and use formatting such as setw(), setprecision(), fixed, and showpoint. (Look ahead in chapter 3 for the discussion of Formatting Output)

Explanation / Answer

i have written code in c++

please find the below code, in case of any query do comment ,

#include<iostream>
#include <iomanip>
using namespace std;

int main(){
  
   double perSharePrice;
   long noOfShare;
   long double totalSharePrice;
   long double sharePriceWithCommision;
   double commision;
  
   cout <<"Enter the Share price : ";
   cin >>perSharePrice;
  
  
   cout <<" Enter the no of share you want to buy ";
   cin >>noOfShare;
   cout<<" Calculating.... price of "<<setprecision(10) <<noOfShare <<" shares at per share price of " <<setprecision(5) <<showpoint<<perSharePrice <<endl;
  
   //Calculatin total share price without commision
   totalSharePrice = noOfShare*perSharePrice;
  
  
   cout <<" Total price of share without any commision : "<<setw(6) <<showpoint <<totalSharePrice<<endl;
  
   //Calculatin Commission
   commision = (2*totalSharePrice)/100;
  
   cout <<" Commmision 2 percent : of transaction amount " <<setprecision(5) <<showpoint <<commision <<endl;
  
   //Calculatin total share price including Commision
   sharePriceWithCommision = commision + totalSharePrice;
  
   cout <<" Total payable cost including commision is "<<setw(6) <<sharePriceWithCommision <<endl;
  
  
}