1. Display Function Implement a function to display the contents of the patient_list array.  Add code to call this function. Note that there are multiple places where this function needs to be called. Look for the  // TODO comments to find the correct locations. Compile and test your program. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The sorting part does not need to work yet.   Take a screenshot of a sample output and upload the picture as part of your assignment submission.   2. Sorting the array by Age   Implement the code to sort the contents of the patient_list array based on the value stored in the age field. To do this you will need to implement code that relies on the qsort function from the C Standard library (see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts: A function that compares two patient elements, based on the value stored in the age field. A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements. Add code to call the qsort function, using the age comparison function that you implemented.  This code should be placed just under the appropriate // TODO comment in main(). Compile and test your program. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The first sorted list should be correct now. Take a screenshot of a sample output and upload the picture as part of your assignment submission.      Sorting the array by Balance Due

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1. Display Function

    1. Implement a function to display the contents of the patient_list array. 
    2. Add code to call this function. Note that there are multiple places where this function needs to be called. Look for the  // TODO comments to find the correct locations.
    3. Compile and test your program.
    4. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The sorting part does not need to work yet.

 

Take a screenshot of a sample output and upload the picture as part of your assignment submission.

 

2. Sorting the array by Age

 

    1. Implement the code to sort the contents of the patient_list array based on the value stored in the age field. To do this you will need to implement code that relies on the qsort function from the C Standard library
      (see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts:
      1. A function that compares two patient elements, based on the value stored in the age field.
      2. A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements.
    2. Add code to call the qsort function, using the age comparison function that you implemented.  This code should be placed just under the appropriate // TODO comment in main().
    3. Compile and test your program.
    4. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The first sorted list should be correct now.

Take a screenshot of a sample output and upload the picture as part of your assignment submission.

 

 

 Sorting the array by Balance Due

 

    1. Implement the code to sort the contents of the patient_list array based on the value stored in the balance field. To do this you will need to implement code that relies on the qsort function from the C Standard library
      (see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts:
      1. A function that compares two patient elements, based on the value stored in the balance field.
      2. A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements.
    2. Add code to call the qsort function, using the balance comparison function that you implemented. This code should be placed just under the appropriate // TODO comment in main().
    3. Compile and test your program.
    4. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The second sorted list should be correct now.

Take a screenshot of a sample output and upload the picture as part of your assignment submission.

 

 Sorting the array by Patient Name

 

    1. Implement the code to sort the contents of the patient_list array based on the value stored in the name field. To do this you will need to implement code that relies on the qsort function from the C Standard library
      (see http://www.cplusplus.com/reference/cstdlib/qsort/). As shown in the reference, this code requires two parts:
      1. A function that compares two patient elements, based on the value stored in the name field. Because name data is stored in an array of characters, you cannot use the relational operators (<, >, <=, … ) to do the comparison, instead you should use a function from the C Standard Library  to determine the order of the names, see (http://www.cplusplus.com/reference/cstring/strncmp/).
      2. A call to the qsort function, which includes the array to be sorted, the number of elements in the array, the size of each array element and the function used to compare the array elements.
    2. Add code to call the qsort function, using the name comparison function that you implemented. This code should be placed just under the appropriate // TODO comment in main().
    3. Compile and test your program.
    4. Make sure that your output is formatted similarly to the sample output shown at the end of this document. The third and final sorted list should be correct now.

 

Take a screenshot of a sample output and upload the picture as part of your assignment submission.

 

Sample (partial) Output for Completed Solution:

Note: this sample output only shows the existing list of patients ; your output should additionally show the entry with your details.

OUTPUT IN IMAGES

Patient List:
Age: 25
Age: 15
Age: 32
Age: 62
Age: 53
Balance Due $: 1250
Balance Due $: 2100
Balance Due $: 750
Balance Due $: 375
Balance Due $: 615
Name: Juan Valdez
Name: James Morris
Name: Tyra Banks
Name: Maria O'Donell
Name: Pablo Picasso
Sorting...
Patient List - Sorted by Age:
Age: 15
Age: 25
Age: 32
Age: 53
Age: 62
Balance Due $: 2100
Balance Due $: 1250
Balance Due $: 750
Name: James Morris
Name: Juan Valdez
Name: Tyra Banks
Name: Pablo Picasso
Name: Maria O'Donell
Balance Due $: 615
Balance Due $: 375
Sorting...
Patient List - Sorted by Balance Due:
Age: 62
Age: 53
Age: 32
Age: 25
Age: 15
Name: Maria O'Donell
Balance Due
Balance Due $: 615
Balance Due $: 750
Balance Due $: 1250
375
Name: Pablo Picasso
Name: Tyra Banks
Name: Juan Valdez
Name: James Morris
Balance Due $: 2100
Sorting...
Patient List - Sorted by Name:
Age: 15
Age: 25
Age: 62
Age: 53
Age: 32
Name: James Morris
Name: Juan Valdez
Name: Maria O'Donell
Balance Due $: 2100
Balance Due $: 1250
Balance Due $: 375
Name: Pablo Picasso
Balance Due $: 615
Name: Tyra Banks
Balance Due $: 750
Transcribed Image Text:Patient List: Age: 25 Age: 15 Age: 32 Age: 62 Age: 53 Balance Due $: 1250 Balance Due $: 2100 Balance Due $: 750 Balance Due $: 375 Balance Due $: 615 Name: Juan Valdez Name: James Morris Name: Tyra Banks Name: Maria O'Donell Name: Pablo Picasso Sorting... Patient List - Sorted by Age: Age: 15 Age: 25 Age: 32 Age: 53 Age: 62 Balance Due $: 2100 Balance Due $: 1250 Balance Due $: 750 Name: James Morris Name: Juan Valdez Name: Tyra Banks Name: Pablo Picasso Name: Maria O'Donell Balance Due $: 615 Balance Due $: 375 Sorting... Patient List - Sorted by Balance Due: Age: 62 Age: 53 Age: 32 Age: 25 Age: 15 Name: Maria O'Donell Balance Due Balance Due $: 615 Balance Due $: 750 Balance Due $: 1250 375 Name: Pablo Picasso Name: Tyra Banks Name: Juan Valdez Name: James Morris Balance Due $: 2100 Sorting... Patient List - Sorted by Name: Age: 15 Age: 25 Age: 62 Age: 53 Age: 32 Name: James Morris Name: Juan Valdez Name: Maria O'Donell Balance Due $: 2100 Balance Due $: 1250 Balance Due $: 375 Name: Pablo Picasso Balance Due $: 615 Name: Tyra Banks Balance Due $: 750
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education