0% found this document useful (0 votes)
14 views2 pages

Blood Type and Rh Factor Input System

The document contains a Java class named BloodData that prompts users to input a patient's blood type and Rhesus factor. It validates the inputs to ensure they are correct before adding the data to a blood bank. The program uses a scanner for user input and includes error handling for invalid entries.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Blood Type and Rh Factor Input System

The document contains a Java class named BloodData that prompts users to input a patient's blood type and Rhesus factor. It validates the inputs to ensure they are correct before adding the data to a blood bank. The program uses a scanner for user input and includes error handling for invalid entries.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

public class BloodData {

static String BloodType;


static String rhFactor;
RunBloodData() {
BloodType=("o");
rhFactor= ("+");
}

public static void main(String[] args) {


Scanner x = new Scanner([Link]);
boolean flag= true;
boolean flag2=true;
BloodData bd= new BloodData();
String input = "";
String rh = "";
while (flag){
[Link]("Enter blood type of the patient:");
input = [Link]();
if([Link]("O")){
flag=false;
}
else if([Link]("A")){
flag=false;
}
else if([Link]("B")){
flag=false;
}
else if([Link]("AB")){
flag=false;
}
else if ([Link]()){
flag=false;
}

else {
[Link]("Wrong input");
}
}
while (flag2){
[Link]("Enter the Rhesus Factor (+ or -):");
rh= [Link]();

if([Link]("+")){
flag2=false;
}
else if ([Link]("-")){
flag2=false;
}
else if ([Link]()){
flag2=false;
}
else {
[Link]("Wrong Input");
}
}

if([Link]() && [Link]()){


[Link]([Link]+ [Link] +"is added to the blood
bank:");

}
else if (!([Link]() && (![Link]()))){

[Link](input+rh + " " + "is added to the blood bank:");

}
}

You might also like