I decided to try learning a bit in java tonight, and I was just trying to try something with the things that I learned.
My question is if statement, how to make two bites true. Here is what I still have.
if ("male".equals(gender)) && ("brendan".equals(name))
The problem, I'm sure, is & & but I'm not sure.
EDIT EDIT EDIT.
This is a fixed part of the problem.
if("male".equals(gender) && "Brendan".equals(name))
and so it happened
if (("male".equals(gender)) && ("brendan".equals(name)))
Now I will post everything that I have another problem, and you probably will need to see all this.
import java.util.Scanner; public class my_input_and_if_statements { public static void main (String args[]) { Scanner jonks = new Scanner(System.in); String name, gender, answer; System.out.println("What is your name?"); name = jonks.next(); System.out.print("Hello "); System.out.print( name); System.out.println(" are you male or female?"); gender = jonks.next(); if (("male".equals(gender)) && ("brendan".equals(name))) { System.out.println("blah blah"); } else { System.out.println(" Welcome to one of my first java applications. I hope you like it"); } if (("female".equals(gender)) && ("nicole".equals(name))) { System.out.println("blah blah 2"); } else { System.out.println(" Welcome to one of my first java applications. I hope you like it"); } } }
Sorry if this seems pointless, just trying to tie some things together before I start trying to find out something else.
now when i go, it gives me two lines when it ends, or it gives me both.
source share