Question
Write a program that helps a hospital analyze the flow of patients through the emergency room. A text input file contains integers that represent the
Write a program that helps a hospital analyze the flow of patients through the emergency room. A text input file contains integers that represent the number of patients that entered the emergency room during each hour of each day for four weeks. Obtain the input file name from a command line argument. Read the information and store it in a three dimensional array. Then analyze it to compare the total number of patients per week, per day, and per hour. Display the results of the analysis please post executable code and execution of the program screenshot.
code required in java.
please post apart from this code
I have considered a csv file as the input which is of the following format: Week,Day,Hour,NumberOfPatients 1,1,1,10 1,1,2,20 1,1,3,30 1,1,4,2 1,1,5,4 1,1,6,3 1,1,7,2 1,1,8,5 and so on.. The Java program that performs the above functionality is: import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public class EmergencyRoom { private static final int NUMBER_OF_WEEKS = 4; private static final int DAYS_PER_WEEK = 7; private static final int HOURS_PER_DAY = 24; public static void main(String[] args) { int array[][][] = new int[NUMBER_OF_WEEKS][DAYS_PER_WEEK][HOURS_PER_DAY]; int numberOfPatients[] = new int[672]; //Total number of records = 4 * 7 * 24 = 672 String csvFile = args[0]; String line = ""; String separator = ","; int count = 0; int totalNumberOfPatients = 0; int numberOfPatientsPerDay = 0; int numberOfPatientsPerHour = 0; try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) { while ((line = br.readLine()) != null) { String[] lineArray = line.split(separator); numberOfPatients[count] = Integer.parseInt(lineArray[3]); totalNumberOfPatients = totalNumberOfPatients + numberOfPatients[count]; count++; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } count = 0; int numberOfPatientsForTheDay; int numberOfPatientsForTheWeek; for (int i = 1; i <= NUMBER_OF_WEEKS; i++) { System.out.println(" Week " + i + ":"); numberOfPatientsForTheWeek = 0; for (int j = 1; j <= DAYS_PER_WEEK; j++) { numberOfPatientsForTheDay = 0; numberOfPatientsForTheWeek = numberOfPatientsForTheWeek + numberOfPatients[count]; numberOfPatientsPerDay = numberOfPatientsForTheWeek/7; System.out.print("Day " + j + ": "); for (int k = 1; k <= HOURS_PER_DAY; k++) { numberOfPatientsForTheDay = numberOfPatientsForTheDay + numberOfPatients[count]; array[i - 1][j - 1][k - 1] = numberOfPatients[count]; numberOfPatientsPerHour = numberOfPatientsForTheDay/24; count++; System.out.print(array[i - 1][j - 1][k - 1] + " "); } System.out.println("Patients per hour: " + numberOfPatientsPerHour); } System.out.println("Patients per day: " + numberOfPatientsPerDay); } System.out.println("Patients per week: " + totalNumberOfPatients / 4); } }
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