Results 1 to 8 of 8
  1. #1
    Denis2k11 is offline Member
    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    0

    Default Having trouble correcting this code.

    Hi! May I ask someone to correct my code for me? I'm sorry that I constantly asking I'm just putting alot into this course but I feel that it's not paying off :( Can someone explain my mistake and what I did wrong like I'm five years old? I am not getting this. And how do I do that [CODE] [\CODE] thingy???
    Constantly getting the error:

    Encrypt.java:7: error: cannot find symbol
    Number = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter a four-digit number: "));
    symbol: method parseInt(String)

    location: class Integer
    1 error

    [code]
    import javax.swing.JOptionPane;
    public class Encrypt
    {
    public static void main(String[]args)
    {
    int Number, One, Two, Three, Four;
    Number = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter a four-digit number: "));
    One = (((Number / 1000) + 7) % 10);
    Two = ((((Number % 1000) / 100) + 7) % 10);
    Three = (((((Number % 1000) % 100) /10)+ 7) % 10);
    Four = ((((((Number % 1000) % 100) % 10) / 1) + 7) % 10);
    JOptionPane.showMessageDialog(null,"The encrypted number is: " + Three + One + Four + Two);
    }
    }
    [\code]
    Last edited by Denis2k11; 10-13-2012 at 11:50 PM.

  2. #2
    Abizzar is offline Member
    Join Date
    Oct 2012
    Location
    Georgia
    Posts
    7
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    It works perfectly fine.

  3. #3
    Denis2k11 is offline Member
    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    Not for me :-/ Keep getting that 1 error

  4. #4
    Abizzar is offline Member
    Join Date
    Oct 2012
    Location
    Georgia
    Posts
    7
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    Which IDE are you using? I'm using BlueJay lol and it compiles fine. Try importing java.lang.*;

  5. #5
    Denis2k11 is offline Member
    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    Using Crimson editor? How do I import ?

  6. #6
    Abizzar is offline Member
    Join Date
    Oct 2012
    Location
    Georgia
    Posts
    7
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    You know how at the top of the code you did
    Java Code:
    import javax.swing.JOptionPane;
    basically import the package java.lang;. then the top should look like this after you add it. Then compile!
    Java Code:
    import javax.swing.JOptionPane;
    import java.lang.*;

  7. #7
    Denis2k11 is offline Member
    Join Date
    Oct 2012
    Posts
    35
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    Quote Originally Posted by Abizzar View Post
    You know how at the top of the code you did
    Java Code:
    import javax.swing.JOptionPane;
    basically import the package java.lang;. then the top should look like this after you add it. Then compile!
    Java Code:
    import javax.swing.JOptionPane;
    import java.lang.*;


    Unfortunately I keep getting the error :(

  8. #8
    Abizzar is offline Member
    Join Date
    Oct 2012
    Location
    Georgia
    Posts
    7
    Rep Power
    0

    Default Re: Having trouble correcting this code.

    Try installing BlueJ instead.

Similar Threads

  1. Having trouble with code in DrJava
    By jonstewart in forum New To Java
    Replies: 15
    Last Post: 04-07-2011, 11:34 PM
  2. Replies: 3
    Last Post: 02-22-2010, 04:20 AM
  3. trouble understanding code help
    By yasmin k in forum New To Java
    Replies: 4
    Last Post: 11-16-2009, 09:46 PM
  4. Trouble compiling code
    By waelhelbawi in forum New To Java
    Replies: 1
    Last Post: 05-12-2008, 04:25 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
  •