Question: In this program, you will work with a structure representing a LEGO building set, which is defined as follows ( from LegoSet.h ) : largest:

In this program, you will work with a structure representing a LEGO building set, which is defined as follows (from LegoSet.h):
largest: Find and print the set with the most pieces in an array of LegoSet structures using the largestSet() function described below:
unsigned largestSet(LegoSet list[], unsigned n): takes in an array of LegoSet structures, list, and the number of structures in the array, n. Function returns the index of the structure with the most pieces.
You must complete the main function in exam3_struct_main.c as well as the three function definitions in LegoSet.c.
Your final program should recognize three commands:
age: Prompt the user to enter an age and print all sets that are appropriate for someone of that age (in other words, the age input is between the minimum and maximum age for that set, including those endpoints) using the findByAge() function described below:
void findByAge(LegoSet list[], unsigned n, unsigned a): takes in an array of LegoSet structures, list, the number of structures in the array, n, and the desired age, a. Function prints all age-appropriate sets found in list, as well as the total number of sets that were printed. For example, if I enter age 4, the output would be:
exit: Exit the program
In addition, you must write one more function:
void printSet(LegoSet* ls): Given a pointer to a LegoSet structure, print the contents of that structure to match one of the two formats below. If the maximum age in the structure is 99, the output should match this form, showing only the minimum age:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!