public class BloodData {
static String BloodType;
static String rhFactor;
RunBloodData() {
BloodType=("o");
rhFactor= ("+");
}
public static void main(String[] args) {
Scanner x = new Scanner(System.in);
boolean flag= true;
boolean flag2=true;
BloodData bd= new BloodData();
String input = "";
String rh = "";
while (flag){
System.out.println("Enter blood type of the patient:");
input = x.nextLine();
if(input.equalsIgnoreCase("O")){
flag=false;
}
else if(input.equalsIgnoreCase("A")){
flag=false;
}
else if(input.equalsIgnoreCase("B")){
flag=false;
}
else if(input.equalsIgnoreCase("AB")){
flag=false;
}
else if (input.isEmpty()){
flag=false;
}
else {
System.out.println("Wrong input");
}
}
while (flag2){
System.out.println("Enter the Rhesus Factor (+ or -):");
rh= x.nextLine();
if(rh.equals("+")){
flag2=false;
}
else if (rh.equals("-")){
flag2=false;
}
else if (rh.isEmpty()){
flag2=false;
}
else {
System.out.println("Wrong Input");
}
}
if(input.isEmpty() && rh.isEmpty()){
System.out.println(bd.BloodType+ bd.rhFactor +"is added to the blood
bank:");
}
else if (!(input.isEmpty() && (!rh.isEmpty()))){
System.out.println(input+rh + " " + "is added to the blood bank:");
}
}