import java.util.Scanner; public class RunBloodData { public static void main(String[] args) { Scanner SC = new Scanner(System.in); String b_Type,r_Factor; System.out.print("Enter blood type of patient: "); b_Type=SC.nextLine(); System.out.print("Enter the Rhesus factor (+ or -): "); r_Factor=SC.nextLine(); BloodData b_data; if(b_Type.equals("")&& r_Factor.equals("")) { b_data=new BloodData(); b_data.display(); } else { b_data=new BloodData(b_Type,r_Factor); b_data.display(); } } } class BloodData{ static String bloodType; static String rhFactor; public BloodData() { bloodType="O"; rhFactor="+"; } public BloodData(String b_Type,String r_Factor) { bloodType=b_Type; rhFactor=r_Factor; } public void display(){ System.out.println(bloodType+rhFactor+" is added to the bloodbank.\n"); } }
import java.util.Scanner; public class RunBloodData { public static void main(String[] args) { Scanner SC = new Scanner(System.in); String b_Type,r_Factor; System.out.print("Enter blood type of patient: "); b_Type=SC.nextLine(); System.out.print("Enter the Rhesus factor (+ or -): "); r_Factor=SC.nextLine(); BloodData b_data; if(b_Type.equals("")&& r_Factor.equals("")) { b_data=new BloodData(); b_data.display(); } else { b_data=new BloodData(b_Type,r_Factor); b_data.display(); } } } class BloodData{ static String bloodType; static String rhFactor; public BloodData() { bloodType="O"; rhFactor="+"; } public BloodData(String b_Type,String r_Factor) { bloodType=b_Type; rhFactor=r_Factor; } public void display(){ System.out.println(bloodType+rhFactor+" is added to the bloodbank.\n"); } }
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images