0% found this document useful (0 votes)
137 views3 pages

Patient Admission System for Dengue

This Java program uses a do-while loop to input patient data, check for conditions requiring admission (a history of bleeding, high urea or low protein levels), and tally the numbers of patients admitted and discharged. It prompts the user to enter a patient's name, bleeding history, urea and protein levels, determines if admission is necessary, and repeats in a loop until the user chooses to stop entering patients. Finally, it prints the numbers of patients admitted and discharged.

Uploaded by

Sn Lau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
137 views3 pages

Patient Admission System for Dengue

This Java program uses a do-while loop to input patient data, check for conditions requiring admission (a history of bleeding, high urea or low protein levels), and tally the numbers of patients admitted and discharged. It prompts the user to enter a patient's name, bleeding history, urea and protein levels, determines if admission is necessary, and repeats in a loop until the user chooses to stop entering patients. Finally, it prints the numbers of patients admitted and discharged.

Uploaded by

Sn Lau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

*;
/*
* Sample Solution for Assignment 1
* BIT106/DIP215 Semester 3, 2014
*/
public class Assignment1Dengue {

public static void main(String[] args)
{
Scanner sc = new Scanner([Link]);
int numAdmitted = 0;
int numDischarged = 0;

char another;

do // main loop to get a patient
{
String name;
do // input and validate name
{
[Link]("Enter patient name :");
name= [Link]();
if ([Link](""))
[Link]("Name cannot be blank");
} while ([Link](""));

boolean needToAdmit = false; // assume that
by default, no need to admit

// input and validate history of bleeding
[Link]("Does patient have history of
bleeding? ");
char bleeding = [Link]().charAt(0);
while (!(bleeding =='y' || bleeding=='Y' ||
bleeding=='N' ||bleeding == 'n'))
{
[Link]("Please enter Y or N");
[Link]("Does patient have history of
bleeding? ");
bleeding = [Link]().charAt(0);
}

if (bleeding == 'Y' || bleeding == 'y')
needToAdmit = true;
else // no bleeding history
{ // check urea
[Link]("Enter patient's urea level");
double urea = [Link]();
while (urea < 0 || urea > 10)
{
[Link]("Error. Urea level must
be between 0 and 10");
[Link]("Enter patient's urea
level");
urea = [Link]();
}
[Link]();

if (urea > 4)
needToAdmit = true;
else // urea is less than or equal to 4
{ // check protein
[Link]("Enter patient's protein
level");
double protein = [Link]();
while (protein < 0 || protein > 150)
{
[Link]("Error. Protein
level must be between 0 and 150");
[Link]("Enter patient's
protein level");
protein = [Link]();
}
[Link]();

if (protein <= 67)
needToAdmit = true;
}

}

// check if need to admit
if (needToAdmit)
{
[Link]("Please admit the patient
immediately");
numAdmitted++;
}
else
{
[Link]("Patient can be discharged");
numDischarged++;

}
do
{
[Link]("Do you want to enter another
patient?");
another = [Link]().charAt(0);
} while (!(another =='y' || another=='Y' ||
another=='N' ||another == 'n'));
} while (another=='y'|| another == 'Y');

// print summary
[Link]("Number of patients admitted :" +
numAdmitted);
[Link]("Number of patients discharged :" +
numDischarged);

}
}

You might also like