Starting from:

$23.99

Flow of Patient Arrivals-Assignment 1 Solution

LabAssignment 1
ProblemDescription
Your task is to design a program to help a hospital analyze the flow of patient arrivals in their emergency room. Atextfilecontainspatientarrivals7daysaweek,24hoursadayfor4weeks. Eachvaluerepresents the number of patients that entered the emergency room during a given hour. Each row in the data file contains 24 values, one for each hour in the day, for all 7 days of the week. Each row contains 24*7 or 168 values. The first set of values in each row is for day zero or Sunday of each week. Each hour is based on militarytimewithhour0being12am,andhour23being11pm.
Requirements
Readdatafromatextfileintoa3dimensionalarray. Fromthedata,compute: 1. thetotalnumberofpatientsthatenteredtheemergencyroomperweek 2. thetotalnumberofpatientsthatenteredtheemergencyroomperdayforeachweek 3. theaveragenumberofdailypatientvisitsperweek 4. thenumberofpatientvisitsperday,averagedoverallweeks 5. thebusiestdayforeachweek 6. theleastbusydayforeachweek Each of these requirements directly corresponds to a function you must implement. See the following sectiononSpecificationsformoredetails.
Specifications
Implement the ERDataReader.java and ERDataAnalyzer.java modules according to the predefined class methods. These predefined class methods serve as the public API (application program interface) for your modules. Youarenotpermittedtochangetheexistingskeletonofclassandmethoddeclarations. However, you are encouraged to create additional private methods to help simplify the process of implementing the publicinterface. TheERDataReaderandERDataAnalyzerclassesexistintheer_datapackage.
Readingthedata Implement the readData() function of the ERDataReader module. The readData function does not need to perform any exception handling. In its function declaration, it specifies what exceptions it may throw. It will
LabAssignment№1 WestVirginiaUniversity Page1
betheresponsibilityofotherprogramswhichuse,or"consume,"thisfunctiontohandlethoseexceptions. TheERDataReadermodulemusthavethefollowingsignature:
Listing1: ERDataReaderModule
1 public class ERDataReader { 2 public static int[][][] readData(String dataFile) 3 throws FileNotFoundException, NoSuchElementException, IllegalStateException ← -{} 4 }
Analyzingthedata ImplementERDataAnalyzerclassinterfacewiththefollowingpublicmethods:
Listing2: ERDataAnalyzerModule
1 public class ERDataAnalyzer { 2 public static int[] patientsPerWeek(int[][][] data) {} 3 public static int[][] patientsPerDayPerWeek(int[][][] data) {} 4 public static double[] averagePatientsPerWeek(int[][][] data) {} 5 public static double[] averagePatientsPerDayAcrossWeeks(int[][][] data) {} 6 public static int[] busiestDayPerWeek(int[][][] data) {} 7 public static int[] leastBusyDayPerWeek(int[][][] data) {} 8 }
APIConsumption Note that the class methods are all declared as static. This design decision has certain implications. The primary implication is that the classes do not need to be "instantiated" in order for their methods to be accessed. Noticeinthefollowingcodeblockonlines13and20wherethereadData()andpatientsPerWeek() methodsareinvokeddirectlyontheclassinsteadofonaninstanceoftheclass. Therefore,youcanexpect yourmodulestobeusedinthefollowingmanner:
Listing3: APIConsumption: ExampleUseCase 1 import er_data.ERDataReader; 2 import er_data.ERDataAnalyzer; 3 import java.io.FileNotFoundException; 4 5 public class Assignment1 { 6 public static void main(String[] args){ 7 String dataFile = "path/to/data"; 8 9 int[][][] data = // initialize array 10 try {
LabAssignment№1 WestVirginiaUniversity Page2
11 data = ERDataReader.readData(dataFile); 12 } catch (FileNotFoundException e) { 13 System.err.println("File cannot be found or accessed: " + dataFile); 14 } catch (Exception e) { 15 e.printStackTrace(); 16 } 17 18 int[] patientsPerWeek = ERDataAnalyzer.patientsPerWeek(data); 19 System.out.println("Patients per week: " + patientsPerWeek); 20 // Calls to other ERDataAnalyzer functions... 21 } 22 }
Remember, as the ERDataReader and ERDataAnalyzer modules will be used in the scope of a larger program(whichyoudonothavetowrite),itiscriticaltoadheretotheAPIspecifications.
FurtherInstructions
Forthislabassignment,youmaychoosetoworkwithonepartner.
Deliverables IwillwriteaprogramwhichcallsyourAPIandchecksthecorrectnessoftheoutput. Youarealsoexpected towritereadable,well-structuredcodetothebestofyourability. EachstudentmustsubmitviaECampusthefollowing: 1. ERDataReader.java-thecodefortheERDataReadermodule 2. ERDataAnalyzer.java-thecodefortheERDataAnalyzermodule If you are working in a group, both students should individually submit their versions of the two files. Also, includeyourteammate’snameinacommentatthetopofeachfile.
SubmissionDeadlines ForSection11(MondayLab): Theassignmentisdueby6:00pm,MondayJanuary16th. ForSection12(TuesdayLab): Theassignmentisdueby3:30pm,TuesdayJanuary17th. Lateassignmentsarenotaccepted. For assistance, feel free to post questions on Slack (for simpler questions), or email me for more in-depth help.

More products