Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume a struct type Money with two int fields, dollars and cents , has been dec

ID: 3556293 • Letter: A

Question

Assume a struct type Money with two int fields, dollars and cents, has been declared. Consider the following declaration:

   struct AutoPart {

        string     partNumber;

        Money    price;

};

AutoPart muffler;

A) Assume that the fields of variable muffler have been assigned valid values. Write code to display the fields of variable mufler on the standard output device. Make sure to call the function displayMoney defined in a previous problem.

B) Write code to set the partNumber field of variable muffler to TC2234  and its price field to $156.99.

Assume a struct type Money with two int fields, dollars and cents, has been declared. Consider the following declaration:

   struct AutoPart {

        string     partNumber;

        Money    price;

};

AutoPart muffler;

A) Assume that the fields of variable muffler have been assigned valid values. Write code to display the fields of variable mufler on the standard output device. Make sure to call the function displayMoney defined in a previous problem.

B) Write code to set the partNumber field of variable muffler to TC2234  and its price field to $156.99.

Explanation / Answer

struct AutoPart
{
    string partNumber;
    Money price;
};
AutoPart muffler;

A) Assume that the fields of variable muffler have been assigned valid values.
Write code to display the fields of variable mufler on the standard output device.
Make sure to call the function displayMoney defined in a previous problem.

cout << muffler.partNumber << " " << displayMoney(muffler.price) << endl;

B) Write code to set the partNumber field of variable muffler to TC2234 and its price field to $156.99

muffler.partNumber = "TC2234";
muffler.price = 156.99;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote