Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ requirements The commission percentage (see below) must be put into a const double variable that you will use in your calculations. The numeric variables

C++ requirements

The commission percentage (see below) must be put into a const double variable that you will use in your calculations. The numeric variables in your program need to be of type double.

Failure to follow the C++ requirements could reduce the points received from passing the tests.

General overview

Next you will read in the number of shares of stock, a stock purchase price, and a stock sale price. The number of shares will always be an integer value.

With this data calculate the total amount required to purchase the stock. You also need to calculate the commission that has to be paid to the stockbroker. The stockbroker commission will be 3.5% of the amount required to purchase the stock.

Note: the commission percentage must be put into a const double variable that you will use in your calculations. The numeric variables in your program need to be of type double.

Output the name of the company, the cost of a share of stock, the total amount required to pay for the stock (not including the commission), the commission, and the total cost of the stock (including the commission).

Next calculate the amount of income you will get when you sell the stock for the stock sales price. You also need to calculate the cost of the commission to the stockbroker for the sale of the stock. Again this will be 3.5% of the money you get for selling the stock.

Output the price of one share of stock, the amount of money you get from the sale (before the commission is paid), the amount of the commission, and the amount of money you get from the sale after you have paid the commission to the stockbroker. All of the money amounts should be output in a fixed format with two digits to the right of the decimal point.

Final calculate the difference between what you paid for the stock (including the commission), and what you received when you sold the stock (less the commission). This number will be negative if you have lost money.

Here is some sample input data:

 

The output from the above input will be:

 

Failure to follow the requirements for lab lessons can result in deductions to your points, even if you pass the validation tests. Logic errors, where you are not actually implementing the correct behavior, can result in reductions even if the test cases happen to return valid answers. This will be true for this and all future lab lessons.

Expected outputimage text in transcribed

here is what i got so far but i keep getting an error

//Description: // This will calculate your gain or loss with the purchase and sell of stocks

#include #include #include using namespace std;

const double Commission = 0.035; // Commission rate of the brocker which is 3.5%

int main() { double PurchasePrice; // The price the stock was purchased at double SoldPrice; // The price the stock was sold at double NumShares; // Number of shares purchased double TotalCost; // Total buying cost double TotalGains; // Total selling cost string CompName; // Company name std::cout

// User inserts company name, purchase price, and the selling price cin >> CompName; cin >> NumShares; cin >> PurchasePrice; cin >> SoldPrice;

// Calculations TotalCost = (PurchasePrice * NumShares) + (PurchasePrice * NumShares * Commission); TotalGains = (SoldPrice * NumShares) + (SoldPrice * NumShares * Commission); // Display Company and Shares cout

// Dispaly Selling Values

cout

//Dispaly gains or loss cout

system ("pause"); return 0;

}

Output the price of one share of stock, the amount of money you get from the sale (before the commission is paid), the amount of the commission, and the amount of money you get from the sale after you have paid the commission to the stockbroker. All of the money amounts should be output in a fixed format with two digits to the right of the decimal point. Final calculate the difference between what you paid for the stock (including the commission), and what you received when you sold the stock (less the commission). This number will be negative if you have lost money Here is some sample input data Acme Software, Inc. 1000 45.50 56.90 The output from the above input will be Company: Acme Software, Inc. Shares: 1000 Purchase/share: $45.50 Cost of stock: $45500.00 Cost of commission: $1592.50 Total cost:$47092.50 Sale/share: $56.90 Income from stock: $56900.00 Cost of commission: $1991.50 Total income: $54908.50 Gain or loss: $7816.00 Failure to follow the requirements for lab lessons can result in deductions to your points, even if you pass the validation tests. Logic errors, where you are not actually implementing the correct behavior, can result in reductions even if the test cases happen to return valid answers. This will be true for this and all future lab lessons. Expected output There are five tests. Each test will have a new set of input data. You must match, exactly, the expected output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions

Question

What are the criterions on Chemical Reaction Equilibria?

Answered: 1 week ago