Answer to Question #26170 in C++ for sumaiya akhter

Question #26170
Ahmed uses the services of a brokerage firm to buy and sell stocks. The firm
charges 1.5% service charges on the total amount for each transaction, buy
or sell. When Ahmed sells stocks, he would like to know if he gained or
lost on a particular investment. Write a program that allows Ahmed to input
the number of shares sold, the purchase price of each share, and the selling price of each share. The program outputs the amount invested, the total service charges, amount gained or lost, and the amount received after selling the stock.
1
Expert's answer
2013-03-12T12:29:28-0400
//Ahmed uses the services of a brokerage firm to buy and sell stocks. The firm
//charges 1.5% service charges on the total amount for each transaction, buy
//or sell. When Ahmed sells stocks, he would like to know if he gained or
//lost on a particular investment. Write a program that allows Ahmed to input
//the number of shares sold, the purchase price of each share, and the selling
//price of each share. The program outputs the amount invested, the total
//service charges, amount gained or lost, and the amount received after
//selling the stock.

# include <iostream>

using namespace std;

int main(){
int n;
cout<<"Enter number:";
cin>>n;
double sp, bp;
double total=0;
for(int i=0;i<n;i++){
cout<<"Enter purchase price:";
cin>>sp;
cout<<"Enter selling price:";
cin>>bp;

cout<<"Cash flow from this operation:";
cout<<bp*0.985 - sp*1.015<<endl;
total+=(bp*0.985 - sp*1.015);
}
cout<<"Total Cash flow:"<<total<<endl;

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS