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);
}
}