SlideShare a Scribd company logo
1 of 8
Download to read offline
package s3;
// Copy paste this Java Template and save it as "EmergencyRoom.java"
import java.util.*;
import java.io.*;
// write your matric number here:
// write your name here:
// write list of collaborators here:
// year 2016 hash code: XAbyuzR78fXeaMHBdLan (do NOT delete this line)
class patientlist {
private String PatientName;
private int emergencyLvl;
public patientlist(String PatientName, int emergencyLvl) {
this.PatientName = PatientName;
this.emergencyLvl = emergencyLvl;
}
public String getPatientName() {
return PatientName;
}
public void setPatientName(String PatientName) {
this.PatientName = PatientName;
}
public int getEmergencyLvl() {
return emergencyLvl;
}
public void setEmergencyLvl(int emergencyLvl) {
this.emergencyLvl = emergencyLvl;
}
}
class EmergencyRoom {
// if needed, declare a private data structure here that
// is accessible to all methods in this class
private List patientlist;
public EmergencyRoom() {
// Write necessary code during construction
patientlist = new ArrayList();
}
void ArriveAtHospital(String patientName, int emergencyLvl) {
// You have to insert the information (patientName, emergencyLvl)
// into your chosen data structure
if (patientName.length() > 15 || patientName.length() < 1) {
System.out.println("patient name is either too long or too short. Please enter a name between 1
to 15 characters.");
} else if (emergencyLvl > 100 || emergencyLvl < 30) {
System.out.println("Emergency level is either too high or too low. Please enter a valid level
between 30 to 100.");
} else {
int i;
for (i = 0; i < patientlist.size(); i++) {
if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) {
System.out.println("Patient already admitted");
break;
}
}
if (i == patientlist.size()) {
patientlist p = new patientlist(patientName.toUpperCase(), emergencyLvl);
patientlist.add(p);
}
}
}
void UpdateEmergencyLvl(String patientName, int incEmergencyLvl) {
// You have to update the emergencyLvl of patientName to
// emergencyLvl += incEmergencyLvl
// and modify your chosen data structure (if needed)
int i;
for (i = 0; i < patientlist.size(); i++) {
if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) {
//System.out.println("Patient already admitted");
//break;
if (incEmergencyLvl > 70 || incEmergencyLvl < 0) {
System.out.println("Emergency level is either too high or too low. Please enter a valid
increment between 0 to 70.");
break;
} else {
patientlist.get(i).setEmergencyLvl(patientlist.get(i).getEmergencyLvl() + incEmergencyLvl);
}
}
}
}
void Treat(String patientName) {
// This patientName is treated by the doctor
// remove him/her from your chosen data structure
int i;
for (i = 0; i < patientlist.size(); i++) {
if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) {
patientlist.remove(i);
}
}
}
String Query() {
String ans = "The emergency room is empty";
int i;
if(patientlist.isEmpty())
return ans;
else{
int max=patientlist.get(0).getEmergencyLvl();
int pos=0;
for (i = 1; i < patientlist.size(); i++) {
if (patientlist.get(i).getEmergencyLvl()>max) {
max=patientlist.get(i).getEmergencyLvl();
pos=i;
}
}
return patientlist.get(pos).getPatientName();
}
// You have to report the name of the patient that the doctor
// has to give the most attention to currently. If there is no more patient to
// be taken care of, return a String "The emergency room is empty"
}
void run() throws Exception {
// do not alter this method
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int numCMD = Integer.parseInt(br.readLine()); // note that numCMD is >= N
while (numCMD-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int command = Integer.parseInt(st.nextToken());
switch (command) {
case 0:
ArriveAtHospital(st.nextToken(), Integer.parseInt(st.nextToken()));
break;
case 1:
UpdateEmergencyLvl(st.nextToken(), Integer.parseInt(st.nextToken()));
break;
case 2:
Treat(st.nextToken());
break;
case 3:
pr.println(Query());
break;
}
}
pr.close();
}
public static void main(String[] args) throws Exception {
// do not alter this method
EmergencyRoom ps1 = new EmergencyRoom();
ps1.run();
}
}
Solution
package s3;
// Copy paste this Java Template and save it as "EmergencyRoom.java"
import java.util.*;
import java.io.*;
// write your matric number here:
// write your name here:
// write list of collaborators here:
// year 2016 hash code: XAbyuzR78fXeaMHBdLan (do NOT delete this line)
class patientlist {
private String PatientName;
private int emergencyLvl;
public patientlist(String PatientName, int emergencyLvl) {
this.PatientName = PatientName;
this.emergencyLvl = emergencyLvl;
}
public String getPatientName() {
return PatientName;
}
public void setPatientName(String PatientName) {
this.PatientName = PatientName;
}
public int getEmergencyLvl() {
return emergencyLvl;
}
public void setEmergencyLvl(int emergencyLvl) {
this.emergencyLvl = emergencyLvl;
}
}
class EmergencyRoom {
// if needed, declare a private data structure here that
// is accessible to all methods in this class
private List patientlist;
public EmergencyRoom() {
// Write necessary code during construction
patientlist = new ArrayList();
}
void ArriveAtHospital(String patientName, int emergencyLvl) {
// You have to insert the information (patientName, emergencyLvl)
// into your chosen data structure
if (patientName.length() > 15 || patientName.length() < 1) {
System.out.println("patient name is either too long or too short. Please enter a name between 1
to 15 characters.");
} else if (emergencyLvl > 100 || emergencyLvl < 30) {
System.out.println("Emergency level is either too high or too low. Please enter a valid level
between 30 to 100.");
} else {
int i;
for (i = 0; i < patientlist.size(); i++) {
if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) {
System.out.println("Patient already admitted");
break;
}
}
if (i == patientlist.size()) {
patientlist p = new patientlist(patientName.toUpperCase(), emergencyLvl);
patientlist.add(p);
}
}
}
void UpdateEmergencyLvl(String patientName, int incEmergencyLvl) {
// You have to update the emergencyLvl of patientName to
// emergencyLvl += incEmergencyLvl
// and modify your chosen data structure (if needed)
int i;
for (i = 0; i < patientlist.size(); i++) {
if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) {
//System.out.println("Patient already admitted");
//break;
if (incEmergencyLvl > 70 || incEmergencyLvl < 0) {
System.out.println("Emergency level is either too high or too low. Please enter a valid
increment between 0 to 70.");
break;
} else {
patientlist.get(i).setEmergencyLvl(patientlist.get(i).getEmergencyLvl() + incEmergencyLvl);
}
}
}
}
void Treat(String patientName) {
// This patientName is treated by the doctor
// remove him/her from your chosen data structure
int i;
for (i = 0; i < patientlist.size(); i++) {
if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) {
patientlist.remove(i);
}
}
}
String Query() {
String ans = "The emergency room is empty";
int i;
if(patientlist.isEmpty())
return ans;
else{
int max=patientlist.get(0).getEmergencyLvl();
int pos=0;
for (i = 1; i < patientlist.size(); i++) {
if (patientlist.get(i).getEmergencyLvl()>max) {
max=patientlist.get(i).getEmergencyLvl();
pos=i;
}
}
return patientlist.get(pos).getPatientName();
}
// You have to report the name of the patient that the doctor
// has to give the most attention to currently. If there is no more patient to
// be taken care of, return a String "The emergency room is empty"
}
void run() throws Exception {
// do not alter this method
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int numCMD = Integer.parseInt(br.readLine()); // note that numCMD is >= N
while (numCMD-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int command = Integer.parseInt(st.nextToken());
switch (command) {
case 0:
ArriveAtHospital(st.nextToken(), Integer.parseInt(st.nextToken()));
break;
case 1:
UpdateEmergencyLvl(st.nextToken(), Integer.parseInt(st.nextToken()));
break;
case 2:
Treat(st.nextToken());
break;
case 3:
pr.println(Query());
break;
}
}
pr.close();
}
public static void main(String[] args) throws Exception {
// do not alter this method
EmergencyRoom ps1 = new EmergencyRoom();
ps1.run();
}
}

More Related Content

Similar to package s3; Copy paste this Java Template and save it as Emer.pdf

Priority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdf
Priority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdfPriority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdf
Priority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdfseamusschwaabl99557
 
import java.util.ArrayList; import java.util.List; import java.u.pdf
import java.util.ArrayList; import java.util.List; import java.u.pdfimport java.util.ArrayList; import java.util.List; import java.u.pdf
import java.util.ArrayList; import java.util.List; import java.u.pdfanupamagarud8
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfankitmobileshop235
 
Need help with this Java practice project. Im brand new to coding s.pdf
Need help with this Java practice project. Im brand new to coding s.pdfNeed help with this Java practice project. Im brand new to coding s.pdf
Need help with this Java practice project. Im brand new to coding s.pdfamazonedistributors
 
Given the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdfGiven the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdfNicholasflqStewartl
 
Hello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfHello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfbarristeressaseren71
 
public class Patient extends Person {=========== Properties ====.pdf
public class Patient extends Person {=========== Properties ====.pdfpublic class Patient extends Person {=========== Properties ====.pdf
public class Patient extends Person {=========== Properties ====.pdfarishmarketing21
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfnipuns1983
 
Implement in C++Create a class named Doctor that has three member .pdf
Implement in C++Create a class named Doctor that has three member .pdfImplement in C++Create a class named Doctor that has three member .pdf
Implement in C++Create a class named Doctor that has three member .pdfcronkwurphyb44502
 
Struggling to Create Maintainable Unit Tests?
Struggling to Create Maintainable Unit Tests?Struggling to Create Maintainable Unit Tests?
Struggling to Create Maintainable Unit Tests?Alistair McKinnell
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfanushkaent7
 
Evolutionary Nursery
Evolutionary NurseryEvolutionary Nursery
Evolutionary Nurseryadil raja
 
Below is my program, I just have some issues when I want to check ou.pdf
Below is my program, I just have some issues when I want to check ou.pdfBelow is my program, I just have some issues when I want to check ou.pdf
Below is my program, I just have some issues when I want to check ou.pdfdhavalbl38
 
Array with Iterator. Java styleImplement an array data structure a.pdf
Array with Iterator. Java styleImplement an array data structure a.pdfArray with Iterator. Java styleImplement an array data structure a.pdf
Array with Iterator. Java styleImplement an array data structure a.pdffcaindore
 
exp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfexp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfmounikanarra3
 
Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfankitmobileshop235
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Ritika sahu
 

Similar to package s3; Copy paste this Java Template and save it as Emer.pdf (20)

Priority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdf
Priority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdfPriority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdf
Priority Queue as a Heap ArrayEmergency Room Patient AdmittanceO.pdf
 
import java.util.ArrayList; import java.util.List; import java.u.pdf
import java.util.ArrayList; import java.util.List; import java.u.pdfimport java.util.ArrayList; import java.util.List; import java.u.pdf
import java.util.ArrayList; import java.util.List; import java.u.pdf
 
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdfBasicPizza.javapublic class BasicPizza { Declaring instance .pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
 
Need help with this Java practice project. Im brand new to coding s.pdf
Need help with this Java practice project. Im brand new to coding s.pdfNeed help with this Java practice project. Im brand new to coding s.pdf
Need help with this Java practice project. Im brand new to coding s.pdf
 
Given the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdfGiven the following errors and class in Java- How are these errors fix.pdf
Given the following errors and class in Java- How are these errors fix.pdf
 
Hello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdfHello. Im creating a class called Bill. I need to design the class.pdf
Hello. Im creating a class called Bill. I need to design the class.pdf
 
public class Patient extends Person {=========== Properties ====.pdf
public class Patient extends Person {=========== Properties ====.pdfpublic class Patient extends Person {=========== Properties ====.pdf
public class Patient extends Person {=========== Properties ====.pdf
 
package employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdfpackage employeeType.employee;public abstract class Employee {  .pdf
package employeeType.employee;public abstract class Employee {  .pdf
 
Exception
ExceptionException
Exception
 
Implement in C++Create a class named Doctor that has three member .pdf
Implement in C++Create a class named Doctor that has three member .pdfImplement in C++Create a class named Doctor that has three member .pdf
Implement in C++Create a class named Doctor that has three member .pdf
 
Struggling to Create Maintainable Unit Tests?
Struggling to Create Maintainable Unit Tests?Struggling to Create Maintainable Unit Tests?
Struggling to Create Maintainable Unit Tests?
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
 
Evolutionary Nursery
Evolutionary NurseryEvolutionary Nursery
Evolutionary Nursery
 
Below is my program, I just have some issues when I want to check ou.pdf
Below is my program, I just have some issues when I want to check ou.pdfBelow is my program, I just have some issues when I want to check ou.pdf
Below is my program, I just have some issues when I want to check ou.pdf
 
Array with Iterator. Java styleImplement an array data structure a.pdf
Array with Iterator. Java styleImplement an array data structure a.pdfArray with Iterator. Java styleImplement an array data structure a.pdf
Array with Iterator. Java styleImplement an array data structure a.pdf
 
exp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdfexp227-jan-170127160848 (3) (1).pdf
exp227-jan-170127160848 (3) (1).pdf
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdf
 
Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.Hospital management project_BY RITIKA SAHU.
Hospital management project_BY RITIKA SAHU.
 
Core Java
Core JavaCore Java
Core Java
 

More from arakalamkah11

Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf
Particulars $Amount Direct materials 64452 Direct Labour (1332.pdfarakalamkah11
 
Decrease in inventory Source of cash $   440 Decrease in account.pdf
    Decrease in inventory Source of cash $   440   Decrease in account.pdf    Decrease in inventory Source of cash $   440   Decrease in account.pdf
Decrease in inventory Source of cash $   440 Decrease in account.pdfarakalamkah11
 
Diamond is sp3 covalent. It makes for bonds to ne.pdf
                     Diamond is sp3 covalent. It makes for bonds to ne.pdf                     Diamond is sp3 covalent. It makes for bonds to ne.pdf
Diamond is sp3 covalent. It makes for bonds to ne.pdfarakalamkah11
 
Too low. If you do not dry the sodium thiosulfate.pdf
                     Too low. If you do not dry the sodium thiosulfate.pdf                     Too low. If you do not dry the sodium thiosulfate.pdf
Too low. If you do not dry the sodium thiosulfate.pdfarakalamkah11
 
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdfarakalamkah11
 
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdfarakalamkah11
 
Light is a form of energy that can be released by.pdf
                     Light is a form of energy that can be released by.pdf                     Light is a form of energy that can be released by.pdf
Light is a form of energy that can be released by.pdfarakalamkah11
 
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdfarakalamkah11
 
Youre looking for Ka, the dissociation constant.pdf
                     Youre looking for Ka, the dissociation constant.pdf                     Youre looking for Ka, the dissociation constant.pdf
Youre looking for Ka, the dissociation constant.pdfarakalamkah11
 
Okay so dipole-dipole interactions would occur be.pdf
                     Okay so dipole-dipole interactions would occur be.pdf                     Okay so dipole-dipole interactions would occur be.pdf
Okay so dipole-dipole interactions would occur be.pdfarakalamkah11
 
remote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfremote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfarakalamkah11
 
Title of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfTitle of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfarakalamkah11
 
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfThe answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfarakalamkah11
 
solutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfsolutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfarakalamkah11
 
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfQ1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfarakalamkah11
 
Solution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfSolution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfarakalamkah11
 
Our body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfOur body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfarakalamkah11
 
Once neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfOnce neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfarakalamkah11
 
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfPDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfarakalamkah11
 
1.A hole is the absence of an electron in a particular place in an a.pdf
1.A hole is the absence of an electron in a particular place in an a.pdf1.A hole is the absence of an electron in a particular place in an a.pdf
1.A hole is the absence of an electron in a particular place in an a.pdfarakalamkah11
 

More from arakalamkah11 (20)

Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf    Particulars $Amount   Direct materials 64452   Direct Labour (1332.pdf
Particulars $Amount Direct materials 64452 Direct Labour (1332.pdf
 
Decrease in inventory Source of cash $   440 Decrease in account.pdf
    Decrease in inventory Source of cash $   440   Decrease in account.pdf    Decrease in inventory Source of cash $   440   Decrease in account.pdf
Decrease in inventory Source of cash $   440 Decrease in account.pdf
 
Diamond is sp3 covalent. It makes for bonds to ne.pdf
                     Diamond is sp3 covalent. It makes for bonds to ne.pdf                     Diamond is sp3 covalent. It makes for bonds to ne.pdf
Diamond is sp3 covalent. It makes for bonds to ne.pdf
 
Too low. If you do not dry the sodium thiosulfate.pdf
                     Too low. If you do not dry the sodium thiosulfate.pdf                     Too low. If you do not dry the sodium thiosulfate.pdf
Too low. If you do not dry the sodium thiosulfate.pdf
 
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
1. A bus is a bunch of wires used to connect multiple subsystems. Bu.pdf
 
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
1. E) The vapor pressure of a liquid.Increasing attractive intermo.pdf
 
Light is a form of energy that can be released by.pdf
                     Light is a form of energy that can be released by.pdf                     Light is a form of energy that can be released by.pdf
Light is a form of energy that can be released by.pdf
 
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
1) Presence of jaws with paired fins in fish helps to feed them. Fin.pdf
 
Youre looking for Ka, the dissociation constant.pdf
                     Youre looking for Ka, the dissociation constant.pdf                     Youre looking for Ka, the dissociation constant.pdf
Youre looking for Ka, the dissociation constant.pdf
 
Okay so dipole-dipole interactions would occur be.pdf
                     Okay so dipole-dipole interactions would occur be.pdf                     Okay so dipole-dipole interactions would occur be.pdf
Okay so dipole-dipole interactions would occur be.pdf
 
remote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdfremote operating system installationRemote Installation Services (.pdf
remote operating system installationRemote Installation Services (.pdf
 
Title of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdfTitle of this process is The Project Life Cycle (Phases)The pr.pdf
Title of this process is The Project Life Cycle (Phases)The pr.pdf
 
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdfThe answer is A) Pol II, with twelve subunits on its own, is capable.pdf
The answer is A) Pol II, with twelve subunits on its own, is capable.pdf
 
solutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdfsolutionA=  1    1    0    4    3    1    2    0 .pdf
solutionA=  1    1    0    4    3    1    2    0 .pdf
 
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdfQ1). Gene therapy is an experimental approach to treat the disease b.pdf
Q1). Gene therapy is an experimental approach to treat the disease b.pdf
 
Solution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdfSolution Three modes of DNA replication 1) Semi conservative.pdf
Solution Three modes of DNA replication 1) Semi conservative.pdf
 
Our body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdfOur body is having two line defence system against pathogens.Pathoge.pdf
Our body is having two line defence system against pathogens.Pathoge.pdf
 
Once neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdfOnce neurons are produced, they migrate and modify to form six layer.pdf
Once neurons are produced, they migrate and modify to form six layer.pdf
 
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdfPDU is called Protocol Data Unit.It consists of user data and protoc.pdf
PDU is called Protocol Data Unit.It consists of user data and protoc.pdf
 
1.A hole is the absence of an electron in a particular place in an a.pdf
1.A hole is the absence of an electron in a particular place in an a.pdf1.A hole is the absence of an electron in a particular place in an a.pdf
1.A hole is the absence of an electron in a particular place in an a.pdf
 

Recently uploaded

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaEADTU
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17Celine George
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................MirzaAbrarBaig5
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 

Recently uploaded (20)

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17How to Send Pro Forma Invoice to Your Customers in Odoo 17
How to Send Pro Forma Invoice to Your Customers in Odoo 17
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 

package s3; Copy paste this Java Template and save it as Emer.pdf

  • 1. package s3; // Copy paste this Java Template and save it as "EmergencyRoom.java" import java.util.*; import java.io.*; // write your matric number here: // write your name here: // write list of collaborators here: // year 2016 hash code: XAbyuzR78fXeaMHBdLan (do NOT delete this line) class patientlist { private String PatientName; private int emergencyLvl; public patientlist(String PatientName, int emergencyLvl) { this.PatientName = PatientName; this.emergencyLvl = emergencyLvl; } public String getPatientName() { return PatientName; } public void setPatientName(String PatientName) { this.PatientName = PatientName; } public int getEmergencyLvl() { return emergencyLvl; } public void setEmergencyLvl(int emergencyLvl) { this.emergencyLvl = emergencyLvl; } } class EmergencyRoom { // if needed, declare a private data structure here that // is accessible to all methods in this class private List patientlist; public EmergencyRoom() { // Write necessary code during construction patientlist = new ArrayList();
  • 2. } void ArriveAtHospital(String patientName, int emergencyLvl) { // You have to insert the information (patientName, emergencyLvl) // into your chosen data structure if (patientName.length() > 15 || patientName.length() < 1) { System.out.println("patient name is either too long or too short. Please enter a name between 1 to 15 characters."); } else if (emergencyLvl > 100 || emergencyLvl < 30) { System.out.println("Emergency level is either too high or too low. Please enter a valid level between 30 to 100."); } else { int i; for (i = 0; i < patientlist.size(); i++) { if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) { System.out.println("Patient already admitted"); break; } } if (i == patientlist.size()) { patientlist p = new patientlist(patientName.toUpperCase(), emergencyLvl); patientlist.add(p); } } } void UpdateEmergencyLvl(String patientName, int incEmergencyLvl) { // You have to update the emergencyLvl of patientName to // emergencyLvl += incEmergencyLvl // and modify your chosen data structure (if needed) int i; for (i = 0; i < patientlist.size(); i++) { if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) { //System.out.println("Patient already admitted"); //break; if (incEmergencyLvl > 70 || incEmergencyLvl < 0) { System.out.println("Emergency level is either too high or too low. Please enter a valid increment between 0 to 70.");
  • 3. break; } else { patientlist.get(i).setEmergencyLvl(patientlist.get(i).getEmergencyLvl() + incEmergencyLvl); } } } } void Treat(String patientName) { // This patientName is treated by the doctor // remove him/her from your chosen data structure int i; for (i = 0; i < patientlist.size(); i++) { if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) { patientlist.remove(i); } } } String Query() { String ans = "The emergency room is empty"; int i; if(patientlist.isEmpty()) return ans; else{ int max=patientlist.get(0).getEmergencyLvl(); int pos=0; for (i = 1; i < patientlist.size(); i++) { if (patientlist.get(i).getEmergencyLvl()>max) { max=patientlist.get(i).getEmergencyLvl(); pos=i; } } return patientlist.get(pos).getPatientName(); } // You have to report the name of the patient that the doctor // has to give the most attention to currently. If there is no more patient to
  • 4. // be taken care of, return a String "The emergency room is empty" } void run() throws Exception { // do not alter this method BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int numCMD = Integer.parseInt(br.readLine()); // note that numCMD is >= N while (numCMD-- > 0) { StringTokenizer st = new StringTokenizer(br.readLine()); int command = Integer.parseInt(st.nextToken()); switch (command) { case 0: ArriveAtHospital(st.nextToken(), Integer.parseInt(st.nextToken())); break; case 1: UpdateEmergencyLvl(st.nextToken(), Integer.parseInt(st.nextToken())); break; case 2: Treat(st.nextToken()); break; case 3: pr.println(Query()); break; } } pr.close(); } public static void main(String[] args) throws Exception { // do not alter this method EmergencyRoom ps1 = new EmergencyRoom(); ps1.run(); } } Solution
  • 5. package s3; // Copy paste this Java Template and save it as "EmergencyRoom.java" import java.util.*; import java.io.*; // write your matric number here: // write your name here: // write list of collaborators here: // year 2016 hash code: XAbyuzR78fXeaMHBdLan (do NOT delete this line) class patientlist { private String PatientName; private int emergencyLvl; public patientlist(String PatientName, int emergencyLvl) { this.PatientName = PatientName; this.emergencyLvl = emergencyLvl; } public String getPatientName() { return PatientName; } public void setPatientName(String PatientName) { this.PatientName = PatientName; } public int getEmergencyLvl() { return emergencyLvl; } public void setEmergencyLvl(int emergencyLvl) { this.emergencyLvl = emergencyLvl; } } class EmergencyRoom { // if needed, declare a private data structure here that // is accessible to all methods in this class private List patientlist; public EmergencyRoom() { // Write necessary code during construction patientlist = new ArrayList(); }
  • 6. void ArriveAtHospital(String patientName, int emergencyLvl) { // You have to insert the information (patientName, emergencyLvl) // into your chosen data structure if (patientName.length() > 15 || patientName.length() < 1) { System.out.println("patient name is either too long or too short. Please enter a name between 1 to 15 characters."); } else if (emergencyLvl > 100 || emergencyLvl < 30) { System.out.println("Emergency level is either too high or too low. Please enter a valid level between 30 to 100."); } else { int i; for (i = 0; i < patientlist.size(); i++) { if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) { System.out.println("Patient already admitted"); break; } } if (i == patientlist.size()) { patientlist p = new patientlist(patientName.toUpperCase(), emergencyLvl); patientlist.add(p); } } } void UpdateEmergencyLvl(String patientName, int incEmergencyLvl) { // You have to update the emergencyLvl of patientName to // emergencyLvl += incEmergencyLvl // and modify your chosen data structure (if needed) int i; for (i = 0; i < patientlist.size(); i++) { if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) { //System.out.println("Patient already admitted"); //break; if (incEmergencyLvl > 70 || incEmergencyLvl < 0) { System.out.println("Emergency level is either too high or too low. Please enter a valid increment between 0 to 70."); break;
  • 7. } else { patientlist.get(i).setEmergencyLvl(patientlist.get(i).getEmergencyLvl() + incEmergencyLvl); } } } } void Treat(String patientName) { // This patientName is treated by the doctor // remove him/her from your chosen data structure int i; for (i = 0; i < patientlist.size(); i++) { if (patientlist.get(i).getPatientName().compareToIgnoreCase(patientName) == 0) { patientlist.remove(i); } } } String Query() { String ans = "The emergency room is empty"; int i; if(patientlist.isEmpty()) return ans; else{ int max=patientlist.get(0).getEmergencyLvl(); int pos=0; for (i = 1; i < patientlist.size(); i++) { if (patientlist.get(i).getEmergencyLvl()>max) { max=patientlist.get(i).getEmergencyLvl(); pos=i; } } return patientlist.get(pos).getPatientName(); } // You have to report the name of the patient that the doctor // has to give the most attention to currently. If there is no more patient to // be taken care of, return a String "The emergency room is empty"
  • 8. } void run() throws Exception { // do not alter this method BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out))); int numCMD = Integer.parseInt(br.readLine()); // note that numCMD is >= N while (numCMD-- > 0) { StringTokenizer st = new StringTokenizer(br.readLine()); int command = Integer.parseInt(st.nextToken()); switch (command) { case 0: ArriveAtHospital(st.nextToken(), Integer.parseInt(st.nextToken())); break; case 1: UpdateEmergencyLvl(st.nextToken(), Integer.parseInt(st.nextToken())); break; case 2: Treat(st.nextToken()); break; case 3: pr.println(Query()); break; } } pr.close(); } public static void main(String[] args) throws Exception { // do not alter this method EmergencyRoom ps1 = new EmergencyRoom(); ps1.run(); } }