java programming



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?
sraveendAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
sciuriwareConnect With a Mentor Commented:
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
 
sraveendAuthor Commented:
Could u please give me an example !!!
0
 
sciuriwareCommented:
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
sraveendAuthor Commented:
Thanks a lot,it helped me to write the program correctly!
0
 
sciuriwareCommented:
Ok, you may click [Accept] now.

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

;JOOP!
0
 
sraveendAuthor Commented:
Am sorry i searched & i coudn't get the link Accept........
0
 
sciuriwareCommented:
After every comment ....
0
 
sraveendAuthor Commented:
I could view accept when u gave me the first solution ,but now i could see only a word comment ,after every comment
0
 
sciuriwareCommented:
Are you logged in as yourself?

;JOOP!
0
All Courses

From novice to tech pro — start learning today.