Results 1 to 8 of 8
- 10-13-2012, 11:45 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 24
- Rep Power
- 0
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.
- 10-14-2012, 12:02 AM #2
Member
- Join Date
- Oct 2012
- Location
- Georgia
- Posts
- 7
- Rep Power
- 0
Re: Having trouble correcting this code.
It works perfectly fine.
- 10-14-2012, 12:05 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 24
- Rep Power
- 0
Re: Having trouble correcting this code.
Not for me :-/ Keep getting that 1 error
- 10-14-2012, 12:17 AM #4
Member
- Join Date
- Oct 2012
- Location
- Georgia
- Posts
- 7
- Rep Power
- 0
Re: Having trouble correcting this code.
Which IDE are you using? I'm using BlueJay lol and it compiles fine. Try importing java.lang.*;
- 10-14-2012, 12:51 AM #5
Member
- Join Date
- Oct 2012
- Posts
- 24
- Rep Power
- 0
Re: Having trouble correcting this code.
Using Crimson editor? How do I import ?
- 10-14-2012, 12:58 AM #6
Member
- Join Date
- Oct 2012
- Location
- Georgia
- Posts
- 7
- Rep Power
- 0
Re: Having trouble correcting this code.
You know how at the top of the code you did
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;
Java Code:import javax.swing.JOptionPane; import java.lang.*;
- 10-14-2012, 01:12 AM #7
Member
- Join Date
- Oct 2012
- Posts
- 24
- Rep Power
- 0
- 10-14-2012, 01:13 AM #8
Member
- Join Date
- Oct 2012
- Location
- Georgia
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Having trouble with code in DrJava
By jonstewart in forum New To JavaReplies: 15Last Post: 04-07-2011, 11:34 PM -
Need help correcting - Newbie don't know what's wrong
By Pokora in forum New To JavaReplies: 3Last Post: 02-22-2010, 04:20 AM -
trouble understanding code help
By yasmin k in forum New To JavaReplies: 4Last Post: 11-16-2009, 09:46 PM -
Trouble compiling code
By waelhelbawi in forum New To JavaReplies: 1Last Post: 05-12-2008, 04:25 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks