Need Help..!! F1!!F1.. ;-)

B

bulletant01

I had a problem with my code... can anybody help me with this..? i
cannot input more than 10 no.s. i think it something to do with the
length of my String.. but i cannot figure out wheres the problem. by
the way heres my code>>>>>>>>

/
*********************************************************************************************************/


import javax.swing.*;

public class Automata {


public static void main(String[] args) {



String input = "";
String [] numLet = new String [100];
int [] oddzero = new int[100];
String ans1 = "";
String ans2="";
String choice ="";


do
{
choice = JOptionPane.showInputDialog("\t\t\t"+ ":press One(1)
to accept a string of Odd Number of Zero(0) and Even Number of One
(1):"+"\n"+
"\t\t\t"+ ":press One(2) to accept a string of Odd Number of
One(1) and Even Number of Zero(0):"+"\n"+
"\t\t\t"+":press three(3) to exit:"+"\n"+
"\t\t\t"+"ENTER YOUR CHOICE");



switch(Integer.parseInt(choice))
{
case 1:

input = JOptionPane.showInputDialog("ENTER A NUMBER(S) (ONE(1)
AND ZERO(0))");

for(int a = 0; a<input.length();a++)
{
numLet[a] = String.valueOf(input.charAt(a));

}

for(int b = 0; b<input.length();b++)
{
oddzero[b+b] = 1;
oddzero[b+b+1]= 0;
}
for(int c = 0; c<input.length();c++)
{
ans1 = ans1+String.valueOf(oddzero[c]);
ans2 = ans2+String.valueOf(numLet[c]);
}

if (Integer.parseInt(ans1) == Integer.parseInt(ans2))
{

JOptionPane.showMessageDialog(null,"ACCEPTED!!");
}
else
{
JOptionPane.showMessageDialog(null,"NOT ACCEPTED!!");
}

ans1 = "";
ans2 = "";
break;

case 2:

input = JOptionPane.showInputDialog("ENTER A NUMBER(S) (ONE(1)
AND ZERO(0))");

for(int a = 0; a<input.length();a++)
{
numLet[a] = String.valueOf(input.charAt(a));

}

for(int b = 0; b<input.length();b++)
{
oddzero[b+b] = 0;
oddzero[b+b+1]= 1;
}
for(int c = 0; c<input.length();c++)
{
ans1 = ans1+String.valueOf(oddzero[c]);
ans2 = ans2+String.valueOf(numLet[c]);
}

if (Integer.parseInt(ans1) == Integer.parseInt(ans2))
{
JOptionPane.showMessageDialog(null,"ACCEPTED!!");
}
else
{
JOptionPane.showMessageDialog(null,"NOT ACCEPTED!!");
}

ans1 = "";
ans2 = "";

break;

case 3:
JOptionPane.showMessageDialog(null,"EXIT!!");
break;
default:
JOptionPane.showMessageDialog(null,"WRONG CHOICE!!");
break;
}


}
while(Integer.parseInt(choice)!=3);
}


}
 
A

Andrew Thompson

Sub: Need Help..!! F1!!F1.. ;-)

(We) need (or at least, could use) sensible subject
lines for posts, to help sort what is and is not within
our sphere of expertise to answer. It also helps you,
since if people are too busy, they might ignore the vague
subject titles and concentrate on posts where they can
clearly help.

On to the code..

1) That code example had 26 compilation errors due
to line wrap.

I provide a tool to help check line width of postings
and code samples. It can be found at..
<http://pscode.org/twc/>

Please restrict widths of code postings to 65 chars, or at
most, 75, rather than the ..149 chars that sample shows.

2) I find it hard to understand* the instructions provided
in the JOptionPane(s).

(some minutes later) ..and looking at the source does not
explain it for me. Take for example..
":press One(1) to accept a string of Odd Number of
Zero(0) and Even Number of One (1):"

If I enter '1', I then expect the next dialog to accept '110',
which it doesn't. Can you explain the intended process in
more words?

* I am not feeling too bright today.
 
B

bulletant01

hey.. thanx 4 d response. i'll try to improve my subject lines next
time.. but i got you anyway..:)

about the code is done.. i fixed it a while ago.. ur right it didnt
accept the '110'. i had a logic error..
 
B

bulletant01

hey.. thanx 4 d response. i'll try to improve my subject lines next
time.. but i got you anyway..:)

about the code. it is done.. i fixed it a while ago.. ur right it
didnt
accept the '110'. i had a logic problem..
 
S

saul.plonkerton

hey.. thanx 4 d response. i'll try to improve my subject lines next
time.. but i got you anyway..:)

about the code. it is done.. i fixed it a while ago.. ur right it
didnt
accept the '110'. i had a logic problem..


have you ever posted a question to a forum / newsgroup / mailing list
before? you made pretty much every mistake in the book.
 
A

Andrew Thompson

On Jan 7, 3:27 am, (e-mail address removed) wrote:
....
have you ever posted a question to a forum / newsgroup / mailing list
before? ..

That identity shows just two posts to usenet
(though they might have made posts under identities
that are now 'worn out' and abandoned, or to
other forums/mediums).
..you made pretty much every mistake in the book.

Unless they drop their 'smarty pants' replies,
they will not be getting further help from me.
bulletant01, you are a little too clever for
your own good.

The rest of the errors they made, can be fixed
over time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top