Declare a structure weightType that has two integer members:pounds and ounces. P
ID: 3618082 • Letter: D
Question
Declare a structure weightType that has two integer members:pounds and ounces.
Part A:
Write a program that uses structure weightType. That is,declare a variable of weightType, get input from user for thisweight, then display it on screen (i.e., ask user to enter poundsand ounces, read them into members of the structure variable, thendisplay them). No sub-function is required at this point.
For example, if user entered 2 pounds 4 ounces for the firstweight, 3 pounds 6 ounces for the second weight, display the resultas:
weight 1: 2 pounds 4 ounces
weight2: 3 pounds 6 ounces
weight 3 (sum) is: 5pounds 10 ounces
Part C:
Re-write Part B using sub-functions.
weightTypegetWeight(); // use thisfunction to get input for a weightType variable
weightType addWt (weightType,weightType);
// use it to add the two parameter weights and return thetotal
// simply add pounds to pounds and ounces to ounces
Explanation / Answer
please rate - thanks CRAMSTER rule - 1 question per post. I am answering the partB #include using namespace std; struct weightType { int pounds; int ounces; }; int main () { weightType one,two,three; cout one.ounces; cout two.ounces; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.