Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this program, you will work with a structure representing a LEGO building set, which is defined as follows ( from LegoSet.h ) : typedef
In this program, you will work with a structure representing a LEGO building set, which is defined as follows from LegoSet.h:
typedef struct
char name; Name of set
unsigned num; Set number
unsigned pieces; Number of pieces in set
unsigned minAge; Minimum recommended age
unsigned maxAge; Maximum recommended age
LegoSet;
You must complete the main function in examstructmain.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 findByAgeLegoSet 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 ageappropriate sets found in list, as well as the total number of sets that were printed. For example, if I enter age the output would be:
Enter age:
Classic Large Creative Brick Box #
pieces
Ages and up
Disney Ariel's Celebration Boat #
pieces
Ages
DUPLO Town Farm Tractor & Animal Care #
pieces
Ages
Total sets for age :
largest: Find and print the set with the most pieces in an array of LegoSet structures using the largestSet function described below:
unsigned largestSetLegoSet 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.
exit: Exit the program
In addition, you must write one more function:
void printSetLegoSet 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 the output should match this form, showing only the minimum age:
Tree House Building Kit #
pieces
Ages and up
Otherwise, the last line should list both the minimum and maximum ages, as shown below:
Disney Ariel's Celebration Boat #
pieces
Ages
Your program does not have to check for any errorsthe partially written main function already handles error checking.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started