an intensive care unit of Hospital Sg Buloh keeps information on the patients suffering from Covid 19in the following input file named covid.txt. The file contains the patient's gender, name, age and number of days in ward followed by daily temperatures for 50 patients. The symbol ';' indicate the delimiter of the data.
female; Mariam Binti Ramli; 20 4 39.0 39.0 38.5 37.0
female; Aisyah Binti Salleh; 41 3 41.0 39.0 38.0
male; Nuh Harraz bin Amirul; 35 5 41.0 41.0 40.5 40.5 39.0
: : covid.txt
**COULD YOU JUST SHOW ME A COMPLETE PROGRAM FLOWCHART FOLLOWS ALL THE QUESTIONS BELOW INSTEAD OF WRITING THE C++ PROGRAM**
a) Define a record name Covid19 to store patients information as follows:
Patient's gender Patient's name
Patient's age
Number of days in the ward
daily temperature
b) Declare an array named patientInfo of type Covid19 with size 50
c) Read all data from covid.txt
d) Find the total number of male and female patients suffering from covid19
e) Find the youngest and oldest patient's age
f) Find the name of patient whose lengthof stay in the ward is the longest. Display also the days and the number of days temperature above 40.
g) Write all the output into the name summary.txt. A sample output file is given below:
Summary of Covid19 patients:
Total number of male patients: 48 Total number of femal patients: 50
The youngest patient age: 25 {male} The oldest patient age: 65 {male}
The longest length of stay in the ward is 14 days with 7 days temperature above 4*C.
The patient's name is Liman Bin Hafizi {male, 65 years old}.
PLEASE KINDLY EXPLAIN THE FLOWCHART FOR THIS PROBLEM.
Note:
I have some doubt regarding the temperatures above 40...I will check and update that code too...Thank u
=================================
We have to paste the input file in the project folder so that our program can able to detect.
// covid19.txt (Input file)
female; Mariam Binti Ramli; 20 4 39.0 39.0 38.5
37.0
female; Aisyah Binti Salleh; 41 3 41.0 39.0 38.0
male; Nuh Harraz bin Amirul; 35 5 41.0 41.0 40.5 40.5
39.0
=============================================
// Covid19.java
public class Covid19 {
private String gender;
private String name;
private int age;
private int noOfDaysInWard;
private double temps[];
/**
* @param gender
* @param name
* @param age
* @param noOfDaysInWard
* @param temps
*/
public Covid19(String gender, String name, int age,
int noOfDaysInWard,
double[] temps)
{
this.gender = gender;
this.name = name;
this.age = age;
this.noOfDaysInWard =
noOfDaysInWard;
this.temps = new
double[noOfDaysInWard];
for (int i = 0; i <
noOfDaysInWard; i++) {
this.temps[i] =
temps[i];
}
}
/**
* @return the gender
*/
public String getGender() {
return gender;
}
/**
* @param gender
* the gender to set
*/
public void setGender(String gender) {
this.gender = gender;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the age
*/
public int getAge() {
return age;
}
/**
* @param age
* the age to set
*/
public void setAge(int age) {
this.age = age;
}
/**
* @return the noOfDaysInWard
*/
public int getNoOfDaysInWard() {
return noOfDaysInWard;
}
/**
* @param noOfDaysInWard
* the noOfDaysInWard to set
*/
public void setNoOfDaysInWard(int noOfDaysInWard)
{
this.noOfDaysInWard =
noOfDaysInWard;
}
/**
* @return the temps
*/
public double[] getTemps() {
return temps;
}
/**
* @param temps
* the temps to set
*/
public void setTemps(double[] temps) {
this.temps = temps;
}
}
=============================================
// ReadFileCovidData.java
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class ReadFileCovidData {
public static void main(String[] args) {
Covid19 patientInfo[]=new
Covid19[50];
int cnt=0,age,days;
double temps[];
Scanner sc=null;
try {
sc=new
Scanner(new File("covid19.txt"));
while(sc.hasNext())
{
temps=null;
String str=sc.nextLine();
String arr[]=str.split("; ");
String arr1[]=arr[2].split("
");
age=Integer.parseInt(arr1[0]);
days=Integer.parseInt(arr1[1]);
temps=new double[days];
for(int i=0;i<days;i++)
{
temps[i]=Double.parseDouble(arr1[i+2]);
}
patientInfo[cnt]=new
Covid19(arr[0],arr[1],age,days, temps);
cnt++;
}
sc.close();
int
arr[]=countMaleAndFemalePatients(patientInfo,cnt);
System.out.println("Total number of male patients: "+arr[0]+" Total
number of femal patients: "+arr[1]);
int
ageMinMaxIndex[]=getMInMaxAge(patientInfo,cnt);
System.out.print("The youngest patient age
:"+patientInfo[ageMinMaxIndex[0]].getAge()+"("+patientInfo[ageMinMaxIndex[0]].getGender()+")
");
System.out.println("The Oldest patient age
:"+patientInfo[ageMinMaxIndex[1]].getAge()+"("+patientInfo[ageMinMaxIndex[1]].getGender()+")
");
} catch (FileNotFoundException e)
{
System.out.println(e.getMessage());
}
}
private static int[] getMInMaxAge(Covid19[]
patientInfo, int cnt) {
int minIndex=0;
int maxIndex=0;
for(int i=0;i<cnt;i++)
{
if(patientInfo[minIndex].getAge()>patientInfo[i].getAge())
{
minIndex=i;
}
if(patientInfo[maxIndex].getAge()<patientInfo[i].getAge())
{
maxIndex=i;
}
}
int arr[]=new int[2];
arr[0]=minIndex;
arr[1]=maxIndex;
return arr;
}
private static int[]
countMaleAndFemalePatients(Covid19[] patientInfo,
int cnt) {
int arr[]=new int[2];
for(int i=0;i<cnt;i++)
{
if(patientInfo[i].getGender().equalsIgnoreCase("male"))
{
arr[0]++;
}
else
if(patientInfo[i].getGender().equalsIgnoreCase("female"))
{
arr[1]++;
}
}
return arr;
}
}
==============================================
Output:
Total number of male patients: 1 Total number of
femal patients: 2
The youngest patient age :20(female) The Oldest patient age
:41(female)
==============================================
Get Answers For Free
Most questions answered within 1 hours.