part C is what we need to turn in so any help would begreat Declare a structure
ID: 3618233 • Letter: P
Question
part C is what we need to turn in so any help would begreat Declare a structure weightType that has two integer members:pounds and ounces.Part A
Write a program that uses structure weightType. That is, declare avariable of weightType, get input from user for this weight, thendisplay it on screen (i.e., ask user to enter pounds and ounces,read them into members of the structure variable, then displaythem). No sub-function is required at this point.
Part B: Now you want to use the weightType to do some calculations.Declare three variables of weightType, prompt for input for two ofthem, add these two weights together and store the result on thethird, and display the result. No sub-function is required at thispoint. 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); // useit to add the two parameter weights and return the total // simply add pounds to pounds and ounces to ounces part C is what we need to turn in so any help would begreat Declare a structure weightType that has two integer members:pounds and ounces.
Part A
Write a program that uses structure weightType. That is, declare avariable of weightType, get input from user for this weight, thendisplay it on screen (i.e., ask user to enter pounds and ounces,read them into members of the structure variable, then displaythem). No sub-function is required at this point.
Part B: Now you want to use the weightType to do some calculations.Declare three variables of weightType, prompt for input for two ofthem, add these two weights together and store the result on thethird, and display the result. No sub-function is required at thispoint. 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); // useit to add the two parameter weights and return the total // simply add pounds to pounds and ounces to ounces
Explanation / Answer
please rate - thanks I couldn't stand leaving ounces 16 or greater #include #include using namespace std; struct weightType{ int pounds; int ounces; }; weightType getWeight(int); weightType addWt (weightType, weightType); void printWeight(weightType,int); int main() { weightType one,two,three; two=getWeight(2); coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.