You are viewing our Forum Archives. To view or take place in current topics click here.
anybody hace any tips on how to do this
Posted:

anybody hace any tips on how to do thisPosted:

aaron547
  • Ladder Climber
Status: Offline
Joined: Jan 07, 201014Year Member
Posts: 396
Reputation Power: 14
Status: Offline
Joined: Jan 07, 201014Year Member
Posts: 396
Reputation Power: 14
Read in a word and change every second character of that word to a capital Y
#2. Posted:
Bighair
  • Powerhouse
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
Break it down into a array of chars then do and do a for loop and increment it by 2 each time. Then rebuild the string from the chars
#3. Posted:
aaron547
  • Ladder Climber
Status: Offline
Joined: Jan 07, 201014Year Member
Posts: 396
Reputation Power: 14
Status: Offline
Joined: Jan 07, 201014Year Member
Posts: 396
Reputation Power: 14
Bighair wrote Break it down into a array of chars then do and do a for loop and increment it by 2 each time. Then rebuild the string from the chars


for an array of cars would you not need a set word the program has to allow any word to be entered
#4. Posted:
Bighair
  • Powerhouse
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
Nahh what lanuage you doing it in?
#5. Posted:
aaron547
  • Ladder Climber
Status: Offline
Joined: Jan 07, 201014Year Member
Posts: 396
Reputation Power: 14
Status: Offline
Joined: Jan 07, 201014Year Member
Posts: 396
Reputation Power: 14
Bighair wrote Nahh what lanuage you doing it in?


java

jfjfgjfgjkftguygu
#6. Posted:
Bighair
  • Powerhouse
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
i will have a play about with it give me a hour
#7. Posted:
Bighair
  • Powerhouse
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
Status: Offline
Joined: Sep 26, 201014Year Member
Posts: 401
Reputation Power: 17
    static String ChangeWord(String Word)
    {
        //Declare an array of chars
        char[] CharArray = new char[Word.length()];
       
        //Give the array its values.
        for (int i = 0; i<CharArray.length;i++)
        {
            CharArray[i] = Word.charAt(i);
        }
       
        //Change every second char in array. Starting with the second
        for (int i = 1; i < CharArray.length; i+=2)
        {
            CharArray[i] = 'Y';   
        }
       
        //Clear word
        Word = "";
       
        //Rebuild the word
        for (int i = 0; i<CharArray.length;i++)
        {
            Word = Word + CharArray[i];
        }
       
        //Return the value of word
        return Word;
    }


IS what i came up with
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.