Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
Arup got engaged this summer and now its time to decide who exactly is going to attend the wedding. Unfortunately, he and his fianc e
Arup got engaged this summer and now its time to decide who exactly is going to attend the wedding. Unfortunately, he and his fiance know more people than their reception hall can accommodate. Thus, they have to choose only some of their friends and family to invite. In this program, you will help them with this Task using c program Each invitation goes to a family. We typically address each invitation to a single member of a family. In addition, each family is assigned a priority number. A lower priority number indicates that the family is more important. Namely we first invite everyone with priority to the wedding, followed by everyone with priority etc. Thus, the information for each family receiving an invitation is: First name A string of upper case letters Last name A string of upper case letters Number of people in the family A positive integer in between inclusive Priority number A positive integer in between inclusiveIts taboo to only invite some families from a particular priority number because then a distinction has been made between people of equal importance and that can cause of social uneasiness. Its also clear that we want to invite guests in order of priority. Thus, to put together the complete guest list, we must do the following: Sort the guest list by priority, break ties by last name, and then breaking those ties by first name Figure out which priority levels, starting at will get invited. Namely if the total number of guests with priorities through k does NOT exceed the capacity while the total number of guests with priorities through k does exceed the capacity, then the priority levels that get invited are through k Output the final guest list to a file in sorted order by last name, breaking ties by first name. Note that we dont want the final guest list to indicate the priority numbers, as this would probably hurt peoples feelings. These priority numbers are only meant to be used internally to determine who to invite.You are required to design your own functions. Any program written with only one function main will automatically receive a point deduction.It is suggested that you have functions that do the following tasks: Read information from a file into separate arrays Swap elements Sort arrays Print information to a fileIts likely that youll find other functions to write that arent specified here.Input Specification allgueststxtThe input will be from the file allguests.txtThe first line of the file contains a two positive integers, n n representing the number of families that Arup and his fiance know, and c c representing the capacity of their reception hall, in number of people.The next n lines each contain information about one family.Each of these lines has the following information about one family separated by spaces: F L N N and P P F represents the first name, L represents the last name, N the number of people in the family and P represents the priority number of the family. You are guaranteed that no people listed will have the exact same first and last name. Two people might have the same first name and a different two people might have the same last name, but no two people will share both.Output Specification finalguestlisttxtThe first line of the output file should have to positive integers, k the number of families invited to the wedding, and g the actual number of guests, separated by spaces.The next k lines should have one family listed each. These lines should be sorted by last name, breaking ties by sorting by first name. The output for each of these lines should be as follows:LAST, FIRST #PEOPLESample Input File allgueststxtBEN JOHNSON DOUG ESPINOSA SARAH TELLINGER GRANT THOMPSON JENNIFER WEST JACKSON JOHNSON MARTY MCFLY ELIZABETH JAMES MICKEY MOUSE RAJ SHAH Sample Output File finalguestlisttxtESPINOSA, DOUG JOHNSON, BEN JOHNSON, JACKSON MCFLY MARTY MOUSE, MICKEY SHAH, RAJ TELLINGER, SARAH THOMPSON, GRANT
Arup got engaged this summer and now its time to decide who exactly is going to attend the wedding. Unfortunately, he and his fiance know more people than their reception hall can accommodate. Thus, they have to choose only some of their friends and family to invite. In this program, you will help them with this Task using c program Each invitation goes to a family. We typically address each invitation to a single member of a family. In addition, each family is assigned a priority number. A lower priority number indicates that the family is more important. Namely we first invite everyone with priority to the wedding, followed by everyone with priority etc. Thus, the information for each family receiving an invitation is: First name A string of upper case letters Last name A string of upper case letters Number of people in the family A positive integer in between inclusive Priority number A positive integer in between inclusiveIts taboo to only invite some families from a particular priority number because then a distinction has been made between people of equal importance and that can cause of social uneasiness. Its also clear that we want to invite guests in order of priority. Thus, to put together the complete guest list, we must do the following: Sort the guest list by priority, break ties by last name, and then breaking those ties by first name Figure out which priority levels, starting at will get invited. Namely if the total number of guests with priorities through k does NOT exceed the capacity while the total number of guests with priorities through k does exceed the capacity, then the priority levels that get invited are through k Output the final guest list to a file in sorted order by last name, breaking ties by first name. Note that we dont want the final guest list to indicate the priority numbers, as this would probably hurt peoples feelings. These priority numbers are only meant to be used internally to determine who to invite.You are required to design your own functions. Any program written with only one function main will automatically receive a point deduction.It is suggested that you have functions that do the following tasks: Read information from a file into separate arrays Swap elements Sort arrays Print information to a fileIts likely that youll find other functions to write that arent specified here.Input Specification allgueststxtThe input will be from the file allguests.txtThe first line of the file contains a two positive integers, n n representing the number of families that Arup and his fiance know, and c c representing the capacity of their reception hall, in number of people.The next n lines each contain information about one family.Each of these lines has the following information about one family separated by spaces: F L N N and P P F represents the first name, L represents the last name, N the number of people in the family and P represents the priority number of the family. You are guaranteed that no people listed will have the exact same first and last name. Two people might have the same first name and a different two people might have the same last name, but no two people will share both.Output Specification finalguestlisttxtThe first line of the output file should have to positive integers, k the number of families invited to the wedding, and g the actual number of guests, separated by spaces.The next k lines should have one family listed each. These lines should be sorted by last name, breaking ties by sorting by first name. The output for each of these lines should be as follows:LAST, FIRST #PEOPLESample Input File allgueststxtBEN JOHNSON DOUG ESPINOSA SARAH TELLINGER GRANT THOMPSON JENNIFER WEST JACKSON JOHNSON MARTY MCFLY ELIZABETH JAMES MICKEY MOUSE RAJ SHAH Sample Output File finalguestlisttxtESPINOSA, DOUG JOHNSON, BEN JOHNSON, JACKSON MCFLY MARTY MOUSE, MICKEY SHAH, RAJ TELLINGER, SARAH THOMPSON, GRANT
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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