Click here to Skip to main content
15,878,748 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to code a java program using nested selection statement and a while loop that takes user input a word (string) and generates a password based on the following conversion:
 If the character being analyzed is a digit, concatenate the digit character to the new string.
 If the character is a lowercase letter, concatenate the corresponding character to the new string as listed in the table below.
 If the character being analyzed is anything other than a lower-case letter or digit, replace it by an (*) for that character.Also,my program should ask the user for a new word until the user enters ‘NO’, ’no’, or ‘No’ to stop.
Conversion table for each letter
a, b, c , d=#
e, f , g, h=@
i, j, k, l=?
m, n, o, p=%
q, r, s , t=&
u, v, w, x=$
y,z=!

What I have tried:

I tried switch case but i do not know how to replace specific letters in a string.
Posted
Updated 9-Oct-22 18:29pm
v2

1 solution

Create a new string, and add each existing or replaced character to it one at a time. By preference, use a StringBuilder (Java Platform SE 7 )[^] as strings are immutable and convert it to a string at the end.
 
Share this answer
 
Comments
lolilo289 10-Oct-22 7:26am    
How do I replace each letter of string of the user input.The string is not specific….also it has to be a nested selection statement and a while loop….?
OriginalGriff 10-Oct-22 7:52am    
And?
What have you tried?
Where are you stuck?
Did you read what I said above?
lolilo289 10-Oct-22 12:40pm    
I don't understand like how to create a new string for each character.I did string word = kb.next(); After that to replace each character do i use replace?If you can please show me an example or a video where they explain how to replace chracters.....
OriginalGriff 10-Oct-22 13:09pm    
Why would you want to do that?
lolilo289 10-Oct-22 13:13pm    
I should replace the characters of the user input word that's why I did string word = kb.next();.... after that i am stuck because i need to use nested selection statement and a while loop...which is confusing to me.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900