Question

(25) Katia Kool bought 622 shares of a Grade A stock at $21.77 per share and...

(25) Katia Kool bought 622 shares of a Grade A stock at $21.77 per share and she must pay her broker 2.625% commission on the transaction. Betty Boop bought 622 shares of a Grade B stock at $12.44 per share and she must pay her broker 2.125% commission on the transaction. Design (write your pseudocode), code, and test a program that calculates and displays for each transaction 1) the client name and Grade of stock, 2) the amount paid for the stock, 3) the amount of the commission, and 4) the total amount paid (stock cost plus commission). Use constant string type for the names, constant char type for the Grade of stock, and constant double type for the commission rates.

Given this information and the following pieces of code How would I complete the code?

// chStr.cpp

// Put your name here

// Pseudocode

#include

#include <___>

#include

using namespace std;

const string ANAME = "Katia Kool";

const char AGRADE = 'A';

const double COMMISSION_RATE_A = 0.02625;

const ___; . . . // likewise, constants for Betty

int main()

{

       int numberOfShares = 622;                // number of shares

       double pricePerShareA = 21.77;           // price per share

       double pricePerShareB = 12.44;           // price per share

       double stockA, stockB;                   // cost of stock, calculated

       double commissionA, commissionB;        // commission paid, calculated

       double totalA, totalB;                   // total cost, calculated

       // compute cost of the stock purchases

       stockA = pricePerShareA * numberOfShares;

       ___;

// compute amount of the commissions

       commissionA = stockA * COMMISSION_RATE_A;

       ___;

// compute total amounts

       totalA = stockA + commissionA;

       ___;

       // output results

       cout << fixed << showpoint << setprecision(2); // format output

       // your output should appear as below

       return 0;

}

/* Output:

Name: Katia Kool       Grade: A

Stock: $nnnnn.nn

Commission: $nnn.nn

Total: $nnnnn.nn

Name: Betty Boop       Grade: B

Stock: $nnnnn.nn

Commission: $nnn.nn

Total: $nnnnn.nn                  */

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Description:

This is a simple practice problem. Constant can be declared using const modifier. Constant for Client "Betty" can be declared as:
// constants for Betty
const string BNAME = "Betty Boop";
const char BGRADE = 'B';
const double COMMISSION_RATE_B = 0.02125;

Computation for client Katia is already made in the program. So following the same code you have to write code Clint Betty.

Solution:

Copy able code:

// chStr.cpp
// Put your name here
// Pseudocode

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

//constants for Katia
const string ANAME = "Katia Kool";
const char AGRADE = 'A';
const double COMMISSION_RATE_A = 0.02625;

// constants for Betty
const string BNAME = "Betty Boop";
const char BGRADE = 'B';
const double COMMISSION_RATE_B = 0.02125;

int main()
{
   int numberOfShares = 622;                // number of shares
   double pricePerShareA = 21.77;           // price per share
   double pricePerShareB = 12.44;           // price per share

   double stockA, stockB;                   // cost of stock, calculated
   double commissionA, commissionB;        // commission paid, calculated
   double totalA, totalB;                   // total cost, calculated
                                          
   // compute cost of the stock purchases
   stockA = pricePerShareA * numberOfShares;
   stockB = pricePerShareB * numberOfShares;

   // compute amount of the commissions
   commissionA = stockA * COMMISSION_RATE_A;
   commissionB = stockB * COMMISSION_RATE_B;

   // compute total amounts
   totalA = stockA + commissionA;
   totalB = stockB + commissionB;

   // output results
   cout << fixed << showpoint << setprecision(2); // format output

   // Output for Katia
   cout << "Name: " << ANAME << "\tGrade: " << AGRADE << endl;
   cout << "Stock: $" << stockA << endl;
   cout << "Commission: $" << commissionA << endl;
   cout << "Total: $" << totalA << endl;

   cout << endl;

   // Output for Betty
   cout << "Name: " << BNAME << "\tGrade: " << BGRADE << endl;
   cout << "Stock: $" << stockB << endl;
   cout << "Commission: $" << commissionB << endl;
   cout << "Total: $" << totalB << endl;

   return 0;
}

Screenshots of code:

Output:

Add a comment
Know the answer?
Add Answer to:
(25) Katia Kool bought 622 shares of a Grade A stock at $21.77 per share and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT