Bernardo J.

asked • 11/04/21

if Statement on two user inputs

import java.util.Scanner;

public class RunBloodData {

public static void main (String [] args){

Scanner sc = new Scanner(System.in);
System.out.println("Enter blood type of patient:");
String input1 = sc.nextLine();
System.out.println("Enter the Rhesus facator (+ or -):");
String input2 = sc.nextLine();


BloodData bd = new BloodData(input1, input2);
BloodData dbd = new BloodData();
if (){
bd.display();
}
else {
dbd.display();
}
class BloodData{
static String bloodType;
static String rhFactor;
public BloodData(){
bloodType = "O";
rhFactor = "+";
}
public BloodData(String bt, String rh){
this.bloodType = bt;
this.rhFactor = rh;
}
public void display(){
System.out.println(bloodType + rhFactor + "is added to the blood bank");
}
}


I have trouble regarding the if statement on what should I use to run it. I want to be able to use the if statement if the user has put an input it will print out the inputs, but if the user has not put any input, it will only print out the default variables that I have put. But I do not know how to use the if statement regarding multiple user inputs and strings. so I would like to ask on what should I put on the () in the if statement or whether I should use a different statement. Thank you

1 Expert Answer

By:

Gabe U. answered • 11/18/21

Tutor
New to Wyzant

Algebra, Python, and Java Tutoring

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.