You are on page 1of 2

Jhance Giyan Regoniel

BSIT21B

import java.util.*;

class BloodData {

static String bloodType;

static String rhFactor;

public BloodData() {

bloodType = "O";

rhFactor = "+";

public BloodData(String bt, String rh) { // create an overloaded constructor

bloodType = bt;

rhFactor = rh;

public void display() {

System.out.println("Blood Type: " + bloodType);

System.out.println("Rhesus Factor: " + rhFactor);

public class RunBloodData {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);


System.out.print("Enter blood type (O, A, B, AB): ");// named blood type for accepting

String input1 = scanner.nextLine();

System.out.print("Enter Rhesus factor (+ or -): ");// instantiate a blooddata

String input2 = scanner.nextLine();

BloodData bd;

if (input1.isEmpty() || input2.isEmpty()) {

bd = new BloodData();

} else {

bd = new BloodData(input1, input2);

bd.display();// print the confirmation message

You might also like