Question
A virus has hit COD and our class is being called on to assist in flattening the curve! The key to this will be tracking
A virus has hit COD and our class is being called on to assist in flattening the curve!
The key to this will be tracking who has been tested and what their test results are so that reports can be created and hot spots identified.
For this assignment make a set of parallel arrays that store:
- Name
- Zip Code
- Test Result
Your program should be menu-driven and look like the following:
COD Virus Tracker
1 - Enter records
2 - Update test results
3 - Run reports
Please select an option (press Enter to exit):
Option 1 should prompt the user for information:
Enter a name (press Enter to exit):
Enter a zip code:
Enter a test result (P for positive, N for negative, or leave empty):
You should test the zip code to make sure it is 5 digits long. If not, print an error and prompt the user again.
You should check the test result to make sure it is P, N, or empty. If not, print an error and prompt the user again.
All information should be stored in three parallel arrays. You may set your arrays to hold ten items.
Option 2 should prompt the user for a name, search and then display either the name or "Name not found." If the name is found then display the current test result and prompt the user to update it. You may assume the name only appears once in the array.
The current test result may be P (positive), N (negative), or none.
Enter a name to search (press Enter to exit) : Charlie Brown
Name not found
Enter a name to search (press Enter to exit): Lori Lightfoot
Lori Lightfoot
Current test result: None
Enter a new test result (P for positive, N for negative, or leave empty): N
Enter a name to search (press Enter to exit):
Option 3 should prompt the user for the type of report they want to run.
1 - Display test results by Zip Code
2 - Display total test results
Please select an option (press Enter to exit):
Test results by Zip Code
Zip Code Postive Negative Percent Positive
60137 3 5 37.5
60138 2 8 20.0
60555 1 6 14.3
To run this report I would sort the arrays and then traverse the arrays keeping track of positive and negative. If the zip code is the same as the one before it then keep counting, otherwise reset the counters. The module that sorts all three arrays and keeps them in sync is at the bottom of this exam.
Total Test Results
Postive Negative Percent Positive
6 19 24.0
To compute the percent positive, divide the number of positive results by the total number of results. You can ignore the no result/empty items in the array and round the result to one decimal point.
Here is a short program that includes a module called bubblesort3. It takes three arrays and keeps them all in sync as you sort the arrays:
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