Question

In: Computer Science

In C++ Design a program to calculate the stock purchasing and selling transactions. 1. ask the...

In C++

Design a program to calculate the stock purchasing and selling transactions.

1. ask the user to enter the name of the stock purchased, the number of share purchased, and the price per share purchased

2. assume the buyer pays 2% of the amount he paid for the stock purchase as broker commission

3. assume that the buyer sold all stocks. Ask the user to enter the price per share sold.

4. assume the buyer will pay another 2% of the amount he received for selling the stock as broker commission


the program will calculate and display:

1. the amount of money he paid for the stock purchase

2. the amount of commission he paid to the broker for purchase transaction

3. the amount he sold the stock for

4. the amount of commission he paid to the broker for purchase selling

5. the possible profit he made after selling his stock and paying the two commissions to the broker

Requirements:

1. program well documented

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main()
{
string name;
int number,bPrice,sPrice,bTotal,sTotal;
int sCommision,bCommision,profit;
//readin the stack details
cout<<"Enter the name of the stock: ";
cin>>name;
cout<<"Enter number of shares purchased: ";
cin>>number;
cout<<"Price of each share : ";
cin>>bPrice;
// calculating the total amount for stock purchase
bTotal=bPrice * number;
// finding the broker commission
bCommision=bTotal*0.02;
  
//reading the selling price
cout<<"Enter the price of share sold: ";
cin>>sPrice;
  
// finding the total amount he got
sTotal=sPrice*number;
// finding the commission
sCommision=sTotal*0.02;
// finding the profit
profit=sTotal-bTotal;
//removing the 2 broker commission from the profit
profit=profit-bCommision;
profit=profit-sCommision;
  
//printing the details
cout<<"Total amount paid for stock purchase : "<<bTotal<<endl;
cout<<"Amount paid for Broker for stock purchase : "<<bCommision<<endl;
cout<<"Amount after selling the stock : "<<sTotal<<endl;
cout<<"Profit : "<<profit;
  
}


Related Solutions

Design a program (in C++)to calculate the stock purchasing and selling transactions. 1. ask the user...
Design a program (in C++)to calculate the stock purchasing and selling transactions. 1. ask the user to enter the name of the stock purchased, the number of share purchased, and the price per share purchased 2. assume the buyer pays 2% of the amount he paid for the stock purchase as broker commission 3. assume that the buyer sold all stocks. Ask the user to enter the price per share sold. 4. assume the buyer will pay another 2% of...
Write a program that does the following things: in C++ 1 ) ask the user for...
Write a program that does the following things: in C++ 1 ) ask the user for 2 primary colors (red, blue, yellow) [should be in main] 2 ) determine the secondary color the 2 primarily colors make [should be in newColor function] red + blue = purple red + yellow = orange blue + yellow = green 3 ) Print the following message <color1> and <color2> makes <color3>
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display...
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display the area and perimeter of a rectangle with width = 4 and height = 8.
Design and implement a C++ program with functions to calculate the pre-tax charge: If the customer...
Design and implement a C++ program with functions to calculate the pre-tax charge: If the customer subscribes to a phone plan called Plan200, then he is charged $5 for the first 200 minutes. For each additional minutes, the customer will be charged $0.10. If the customer subscribes to a phone plan called Max20, then he is charged $0.05 for each minute up to $20. (I.e., the customer never needs to pay more than $20.) If the customer is not subscribed...
I. Design the C++ code for a program which will use the Pythagorean Theroem to calculate...
I. Design the C++ code for a program which will use the Pythagorean Theroem to calculate and display the length of a right triangle hypotenuse,c, given the lengths of its adjacent sides: a and b.. (hint: a^2 + b^2 = c^2) II. Design the C++ code for a program which will calculate and display the roots of a quadratic equation of the form ax^2 + bx + c = 0, given its coefficients, a, b, and c.
In C++ Write a program to store exam scores into a file. The program will ask...
In C++ Write a program to store exam scores into a file. The program will ask the user how many exam scores to enter. Then it will ask the user for each exam score and store them in a file called scores.dat The file output should have the following format: Exam 1: 97 Exam 2: 85
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate...
C LANGUAGE Ask user how many scores there are, then ask for each score. Then calculate the average score and scores below 60. Then display the average score and number of scores below 60
Design a program that will ask the user to input two integer numbers and then perform...
Design a program that will ask the user to input two integer numbers and then perform the basic arithmetic operations such as addition and subtraction. Each calculation is done by a separate function. The main function gets the input from the user, then calls the addition function and the subtraction function one at a time to perform the calculations. Each calculation function (addition or subtraction function) performs an arithmetic operation and then returns the calculation results back to where it...
create a C++ Program 1. Ask and get a course name 2. Create an array of...
create a C++ Program 1. Ask and get a course name 2. Create an array of students of size 10, 3. Initialize the elements of the students array of appropriate names and grades 4. Create an object of class GradeBook (provide the course name and the created student array, in 3 above, as arguments to the constructor call. The arguments are used to initialize the data members of the class GradeBook. Desired Output: ========================================================= Enter course name: Object Oriented Programming...
Write a program in C++ that calculates the sum of two fractions. The program should ask...
Write a program in C++ that calculates the sum of two fractions. The program should ask for the numerators and denominators of two fractions and then output the sum of the two fractions. You will need to write four functions for this program, one to read the inputted data, one to calculate the sum of the two fractions, one to find the Greatest Common Divider (GCD) between the numerator and denominator and a function that will display the end result....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT