Solved

java programming

Posted on 2004-09-26
9
221 Views
Last Modified: 2010-05-18


This assignment will be creating all the permutations of a word using upper and lower case letters.  For a word that is n letters long the number of permutations is 2n.  For instance; given the word "are" the possible permutations include:

are
Are
ARe
ARE
ArE
aRe
aRE
arE

Please help me to write a java progarm?
0
Comment
Question by:sraveend
  • 5
  • 4
9 Comments
 
LVL 24

Accepted Solution

by:
sciuriware earned 500 total points
ID: 12155165
No, homework is forbidden.

The only thing I will say is that every character has 2 states,
you might couple these to an array of booleans and
that to a split binary number of which the bits indicate the state (0 == lowercase).
By incrementing the binary number you can decode all possible strings.

Just try.

;JOOP!
0
 

Author Comment

by:sraveend
ID: 12159242
Could u please give me an example !!!
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12160040
You must change characters, so you must choose between a char[] (very fast) and a StringBuffer (flexible).

For 3 characters you need:                       char[] array = new char[3];
You can count from 0 to 7 to address them:
       for(int i = 0;  i < 8;  ++i)
You can address those 3 characters by an integer:
              for(j = 0;  j < 3;  ++j)
To address 'array' from 'i' :
       if((i & (1<<j)) == 0)
       {
             array[j] = Character.toLowerCase(array[j]);
       }
       else
       {
             array[j] = Character.toUpperCase(array[j]);
       }


It's your turn now.....
;JOOP!
0
 

Author Comment

by:sraveend
ID: 12168930
Thanks a lot,it helped me to write the program correctly!
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 24

Expert Comment

by:sciuriware
ID: 12170095
Ok, you may click [Accept] now.

Feel free to learn here, not just to copy from here (that's the rules).

;JOOP!
0
 

Author Comment

by:sraveend
ID: 12172853
Am sorry i searched & i coudn't get the link Accept........
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12176662
After every comment ....
0
 

Author Comment

by:sraveend
ID: 12180889
I could view accept when u gave me the first solution ,but now i could see only a word comment ,after every comment
0
 
LVL 24

Expert Comment

by:sciuriware
ID: 12187280
Are you logged in as yourself?

;JOOP!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
base64 decode encode 12 122
java  and programming certification ? 4 86
couple of eclipse 5 25
Oracle SQL syntax check  without executing 6 37
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now