Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a directory named lab9 and download lab9.c as shown below from Blackboard to that directory. This lab maintains a linked list of persons, where

image text in transcribedimage text in transcribed

Create a directory named lab9 and download lab9.c as shown below from Blackboard to that directory. This lab maintains a linked list of persons, where each person contains a name (one-word only) and an age. The program operates as follows Prompts the user for names and ages, building the list with calls to add, printing the list after each add Prompts the user for a name, and then prints the age of that person (-1 if the name is not in the list) You must do the following .Write the function getAge that returns the age of the name passed to it, or -1 if the person does not exist. . Re-write add so that all the persons will be ordered by ascending age. For those with the same age, they will be ordered alphabetically. Do not add a name if it already exists in the list and print an error message. It is recommended to write a helper function comparePerson that compares two persons and returns -1,1 or 0, depending on the positions of the two persons in the linked list. Two sample inputs for the program are shown at the right of the code Create a directory named lab9 and download lab9.c as shown below from Blackboard to that directory. This lab maintains a linked list of persons, where each person contains a name (one-word only) and an age. The program operates as follows Prompts the user for names and ages, building the list with calls to add, printing the list after each add Prompts the user for a name, and then prints the age of that person (-1 if the name is not in the list) You must do the following .Write the function getAge that returns the age of the name passed to it, or -1 if the person does not exist. . Re-write add so that all the persons will be ordered by ascending age. For those with the same age, they will be ordered alphabetically. Do not add a name if it already exists in the list and print an error message. It is recommended to write a helper function comparePerson that compares two persons and returns -1,1 or 0, depending on the positions of the two persons in the linked list. Two sample inputs for the program are shown at the right of the code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Databases Demystified

Authors: Andrew Oppel

1st Edition

0072253649, 9780072253641

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago