Answered step by step
Verified Expert Solution
Link Copied!

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 1 to the wedding, followed by everyone with priority 2, etc.) Thus, the information for each family receiving an invitation is:1) First name (A string of 1-19 upper case letters)2) Last name (A string of 1-19 upper case letters)3) Number of people in the family (A positive integer in between 1-10, inclusive)4) Priority number (A positive integer in between 1-20, inclusive)Its 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:1) Sort the guest list by priority, break ties by last name, and then breaking those ties by first name.2) Figure out which priority levels, starting at 1, will get invited. (Namely, if the total number of guests with priorities 1 through k does NOT exceed the capacity while the total number of guests with priorities 1 through k+1 does exceed the capacity, then the priority levels that get invited are 1 through k.)3) 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.)1You are required to design your own functions. Any program written with only one function (main) will automatically receive a 20 point deduction.It is suggested that you have functions that do the following tasks:1) Read information from a file into separate arrays 2) Swap elements3) Sort arrays4) Print information to a fileIts likely that youll find other functions to write that arent specified here.Input Specification (allguests.txt)The input will be from the file allguests.txt.The first line of the file contains a two positive integers, n (n 1000), representing the number of families that Arup and his fiance know, and c (c 1000), 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 (1 N 10) and P (1 P 20). 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 (finalguestlist.txt)The 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 (allguests.txt)1030BEN JOHNSON 42DOUG ESPINOSA 32SARAH TELLINGER 53GRANT THOMPSON 52JENNIFER WEST 76JACKSON JOHNSON 15MARTY MCFLY 41ELIZABETH JAMES 26MICKEY MOUSE 24RAJ SHAH 252Sample Output File (finalguestlist.txt)826ESPINOSA, DOUG 3JOHNSON, BEN 4JOHNSON, JACKSON 1MCFLY, MARTY 4MOUSE, MICKEY 2SHAH, RAJ 2TELLINGER, SARAH 5THOMPSON, GRANT 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions