Hi, can anybody help me with this? I am doing an Introduction to Programming module using Java and am stuck at this question. Write a program which reads in a username and a password, and expects the username to be "brian" and the password to be "spam". The program should print a welcome message if these are both correct. Thanks.

Lots of people here to help. Can you explain your problem? Post the code you are having problems with and ask any questions you have.

public class Bridget {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub

    String username1; // Username of person
    String password1; // Password of person


    System.out.println (" Please enter a username:()");
    username1 = ;

    System.out.println (" Please enter a " + password1);
    password;

    if username1 = Brian;
    System.out.println("Welcome");

    else
    System.out.println ("Incorrect username");

    if (password1 = spam);
    System.out.println ("Welcome");

    else
    System.out.println("Incorrect password");

}end main( //)

end class //

This is what I have so far.

There are quite a few syntax errors there - missing () etc. Compile your program to get a list of syntax errors and fix them (start at the top and re-compile after each one, as an error early in the code can disrupt parsing of the code that follows).
Then a couple of hints:
To compare Strings you can't use == (even less =, which is assignment). YOU need the equals method (documented in the standard API doc for String)
You can use a Scanner with System.in to read input from the user. Google for more detail.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.