So I'm a beginner in Java right now and I've been playing around with strings a bit. Now I'd like to give the user an input choice "Enter a or b: "
and give an output based on either "a"
or "b"
The Code:
int a = 18;
int b = 22;
Scanner user_input = new Scanner (System.in);
String first_name;
System.out.println("Enter your first name: ");
first_name = user_input.next();
String last_name;
System.out.println("Enter your last name: ");
last_name = user_input.next();
String full_name;
full_name = first_name + " " + last_name;
System.out.println("You are: " + full_name);
String age;
System.out.println("Enter a or b: ");
age = user_input.next();
String age_a;
System.out.println("Your age is 18");
age = user_input(a);
I was also thinking maybe a function could be used like:
if(user_input = a)
{
System.out.println("Your age is 18.");
}