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:
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:
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
- 0useful
- 0not useful
#3. Posted:
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
- 0useful
- 0not useful
#4. Posted:
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?
- 0useful
- 0not useful
#5. Posted:
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
- 0useful
- 0not useful
#6. Posted:
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
- 0useful
- 0not useful
#7. Posted:
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
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.