Objective: Basic programming involving arithmetic, input, and output. Reference:
ID: 3542262 • Letter: O
Question
Objective: Basic programming involving arithmetic, input, and output.
Reference: Read the description of the Exercise 22 on page 154. Your program would be similar but it would accept
input from the user.
Write this program using the programs in the book and Labs 2
Objective: Basic programming involving arithmetic, input, and output. Reference: Read the description of the Exercise 22 on page 154. Your program would be similar but it would accept input from the user. Write this program using the programs in the book and Labs 2 - 4 as examples.The program must contain a header comment block, each major section of the program must be identified by comments (as in the labs) and the statements should line up properly. See the formatting in the book or my sample programs. Both the program and the results should be nice to read.Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int numberOfShares = 0;
float buyingPrice = 0,sellingPrice = 0,commissionRatePercent = 0,totalPaidToBuy=0, commissionToBuy =0, totalFromSale =0,commissionToSale = 0, netProfit = 0;
cout <<"CPS 150 Assignment 1 by __________ KEY _______________ ";
cout << "Welcome to Stock Transaction Program! " << endl;
cout << "Enter the number of shares: ";
cin >> numberOfShares;
cout << endl;
cout << "Enter the buying price of each share: ";
cin >> buyingPrice;
cout <<endl << "Enter the selling price of each share: ";
cin >> sellingPrice;
cout <<endl<<"Enter the commission rate percent: ";
cin >> commissionRatePercent;
totalPaidToBuy = numberOfShares * buyingPrice;
cout<<" Stock Transaction Report"<<endl;
cout<<"========================== ";
cout<<"Total paid to buy shares: $ "<< totalPaidToBuy << endl;
commissionToBuy = (commissionRatePercent * totalPaidToBuy)/100;
cout <<"Commission to buy: $ "<<commissionToBuy<<endl;
totalFromSale = numberOfShares * sellingPrice;
cout <<"Total received from sale: $ "<<totalFromSale <<endl;
commissionToSale = (commissionRatePercent * totalFromSale)/100;
cout <<"Commission to sell: $ "<<commissionToSale<<endl;
netProfit =totalFromSale + commissionToSale - totalPaidToBuy - commissionToBuy;
cout <<"Net Profit (Loss if -) : $ "<<netProfit << endl;
cout <<" Assignment 1 complete" <<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.