Results 1 to 4 of 4
  1. #1
    afisher300 is offline Member
    Join Date
    Mar 2008
    Location
    Colorado
    Posts
    6
    Rep Power
    0

    Default DOnt know if 1st post if did, I am VERY sorry for duplicate post. I have error messg

    The dreaded error message that I am getting and I CANNOT understand lookup anything is: PasswordTest.java:70: class, interface, or enum expected

    I dont know if it is common to copy the whole program so it would be easier to see why the error would be coming from. If this is a problem I am sorry also...

    so if there is anybody that can help this very stuck student in trying to finish their project before school gets out it would br gretly appreciated to anybody who had ANY ideas for me. Thank you much. Slight break down... Password checker, has to check 6 password, check length, must B 6 dig lond, must have lc dig and a uc dig and it must have 1 num dig in it, then count the valid and bad passwords

    import javax.swing.*; //to use JOptionPane
    import java.util.Scanner; // use for Scanner

    public class PasswordTest
    {
    private static String passwordsBeingEntered; // the passwords that are being entered
    private static String testPlansAuthor;// name of the author who is testing their passwords
    private static String reportString; // this is the output string

    private static int numberOfPasswords; // total number of passwords
    private static int validPassword; // how many of the passwards that have been entered are good
    private static int badPassword; //how many of the passwords that have been entered are bad

    private static final int PASSWORD_LENGTH = 6; // minimum number of password there are supposed to be

    private static boolean checkLength = false; // checks to see if the length is 6 or over
    private static boolean checkLowercase = false; // checks to see if password has a lowercase letter
    private static boolean checkUppercase = false; // checks to see if password has a uppercase letter
    private static boolean checkDigit = false; // checks to see if the password has a digit in it

    public static void main(String[] args)
    {
    Scanner keyboard = new Scanner(System.in);

    PasswordTest mypassword = new PasswordTest();

    mypassword.startPasswordChecker();

    for (index = 0; index < 1; index++)
    {
    mypassword.inputPassword();
    // mypassword.checkLength();

    }
    }

    public static void startPasswordChecker()
    {
    System.out.println("Please welcome to the Password Checker Program" +
    "\n\nThis prgram asks the user how many passwords they choose to check" +
    "\n and the computer will determine how many of the passwords are valid and how many are bad");


    numberOfPasswords = Integer.parseInt(JOptionPane.showInputDialog("Plea se enter how many " +
    "passwords you would like to check?"));

    testPlansAuthor = (JOptionPane.showInputDialog("Please enter your name?"));

    // this string that will help with the output at the end of the program
    String reportString = ("Results of Password Checker" +
    "\n\nTest plans were made by " + testPlansAuthor +
    "\nPasswords checked:" + numberOfPasswords +
    "\n Good Passwords:" + validPassword + " bad Passwords" + badPassword);

    }// end of startPasswordChecker method

    //This method allows the user to input the passwords using the scanner option
    public static void inputPassword()
    {
    System.out.println("Please enter the password that you would like tested? ");
    passwordsBeingEntered = keyboard.nextLine();
    inputChar = inputLine.charAt(0);
    }

    }//end of inputPasswordMethod


    // This method checks the length of all passwords submitted to make sure they meed the
    // length required
    public static void checkLength()
    {
    if (passwordsBeingEntered.length() > 6)
    checkLength = true;
    else
    checkLength = false;

    }// end of checkLength Method
    }// end of class

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Do all of your opening and closing braces match up? Look at the code above the line that trips the error message, and you may find the problem there, in particular look at the braces for the inputPassword() method.

    Also, when posting code, if you use code tags, they'll be easier to read. You do this by adding the tag [cod&#101;] above your code block, and the tag [/cod&#101;] below it, like so:

    Java Code:
    [cod&#101;]
      // your code block goes here
    [/cod&#101;]

  3. #3
    afisher300 is offline Member
    Join Date
    Mar 2008
    Location
    Colorado
    Posts
    6
    Rep Power
    0

    Default

    I did find a quick mistake do to someone sending me a replya nd thank you very much that I had an extra brace in my brograming. But now that is bringing an error that i am again not understanding. I am not sure if it deals with the Scanner that I inputed Ther error is.

    PasswordTest.java:61: cannot find symbol
    symbol : variable keyboard
    location: class PasswordTest
    passwordsBeingEntered = keyboard.nextLine();
    ^

    On my screen, the arrow is shown under the k in keyboard. So I was thinking it had somethig to do with keyboard. But I named that object right and thought I used it correctly after naming it. Thank to the ones in the past and thanks to the ones in the future

    Amy

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    This is probably a scope issue: the Scanner variable "keyboard" was declared within the main method, and so its scope is only within that method. In other words, outside of the main method, this variable simply doesn't exist. Solution: declare it in the class, not within the main method.

Similar Threads

  1. Infix to Post fix
    By Tenn in forum New To Java
    Replies: 0
    Last Post: 05-03-2009, 10:21 PM
  2. my first post
    By kaviyasivashanmugham in forum New To Java
    Replies: 2
    Last Post: 03-13-2009, 10:50 AM
  3. First post out of the way..
    By sirwiggles in forum Introductions
    Replies: 0
    Last Post: 02-06-2009, 11:44 PM
  4. First post ever
    By pbpersson in forum Introductions
    Replies: 4
    Last Post: 08-16-2008, 06:30 AM
  5. First post as per request
    By happyknappy in forum Introductions
    Replies: 3
    Last Post: 07-30-2008, 02:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •