In: Computer Science
Write a program using C++ that ask the user for the flowing: How many shares to be bought: The price per share: Percent commission for the broker for each transaction: Average annual return as of percentage: The program should calculate and display the following: The amount paid for the stock alone (without the commission) The amount of the commissionThe total amount of paid (the payment for stock plus the commission) After TEN years, your shares will worth:
Images of code and output-
Code is below-
#include<iostream>
#include<math.h>
using namespace std;
void share_cal(float n_shares,float price,float comm,float
ret)
{
float paid,com,total,ten,ret2,net,finall;
paid= n_shares*price;
com = paid*(comm/100);
total = com + paid;
ret2= (ret/100)+1;
ten = pow((ret2*10),((float)1/10));
net= ten-1;
finall= net*total + total;
cout<<"Amount paid for stock =
"<<paid<<endl;
cout<<"Amount of commission = "<<com<<endl;
cout<<"Total amount paid = "<<total<<endl;
cout<<"Share price after 10 yrs =
"<<finall<<endl;
}
int main()
{
float n_shares,price,comm,ret ;
cout<< "Enter the number of shares to be bought \n";
cin>> n_shares;
cout<<"Enter the price of share \n";
cin>> price;
cout<<"Enter the percent of commission of broker for each
transaction \n";
cin>> comm;
cout<<"Enter the average annual return (in %) \n";
cin>> ret;
share_cal(n_shares,price,comm,ret);
return 0;
}