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

04 Hands-On Activity 1

The code prompts the user to enter a blood type and Rh factor, creates a BloodData object with the input values, and displays and prints the blood type and Rh factor to the console. If no values are entered, it creates a BloodData object with default blood type O and Rh factor +, displays and prints these values. It then prints a message indicating the blood type is added to the blood bank.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
323 views2 pages

04 Hands-On Activity 1

The code prompts the user to enter a blood type and Rh factor, creates a BloodData object with the input values, and displays and prints the blood type and Rh factor to the console. If no values are entered, it creates a BloodData object with default blood type O and Rh factor +, displays and prints these values. It then prints a message indicating the blood type is added to the blood bank.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

public class RunBloodData {

public static void main(String[] args) {

Scanner input = new Scanner (System.in);

System.out.print("Enter blood type of patient: ");

String input1 = input.nextLine();

System.out.print("Enter the Rhesus Factor (+ or -): ");

String input2 = input.nextLine();

BloodData bd = new BloodData(input1,input2);

bd.display();

System.out.println(" is added to the blood bank.");

BloodData bd = new BloodData();

bd.display();

System.out.println(" is added to the blood bank.");

class BloodData {

static String bloodType;

static String rhFactor;

public BloodData() {

bloodType = "O";

rhFactor = "+";

public BloodData(String bt, String rh) {

bloodType = bt;

rhFactor = rh;

}static

public void display(){


System.out.print(bloodType+rhFactor);

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy