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;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.