• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can i make a method to change the middle character of user input without already know the the wo  RSS feed

 
m christian
Greenhorn
Posts: 1
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im pretty new to java and i need a method that replaces any user inputs middle letter with another letter. regardless if the user inputs "abcdef", "frogs", or "pizza" it changes the middle letter to "Q" if i wanted. Im pretty new at this so i dont know how to use arrays yet either. i thought of using **replaceCharAt()** and the **str.length()** but i dont know how to use them together with unknown inputs. any help would be appreciated.

edit: i have included my class and my driver class to show what i am dealing with. i need to change the middle letter of th user inputted **dnaCode** to "Q".

my class so far:

  
My driver class (cant edit due to assignment):

   
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's some math involved man, whatever the length of the string us divided by 2 or something like that.
 
Carey Brown
Saloon Keeper
Posts: 3329
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using substring() method
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!