reset password
Author Message
abubakir
Posts: 14
Posted 11:48 Mar 18, 2017 |

any hints on how to replace vowels in a string

kknaur
Posts: 540
Posted 12:01 Mar 18, 2017 |

Don't think of it so much as replacing the vowels in the original string, but creating a new string and instead of adding a vowel you add the _ character when the character you are considering is a vowel.

jgarc629
Posts: 76
Posted 01:31 Mar 19, 2017 |

How can you count the vowels and other words? Any hints?

Last edited by jgarc629 at 02:01 Mar 19, 2017.
jzunig20
Posts: 38
Posted 02:01 Mar 19, 2017 |
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

jgarc629
Posts: 76
Posted 02:03 Mar 19, 2017 |
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

jzunig20
Posts: 38
Posted 02:06 Mar 19, 2017 |

if you start a variable inside a loop, the scope is only within the loop, if you start a variable inside a nested loop, the scope is only within that particular loop

jzunig20
Posts: 38
Posted 02:10 Mar 19, 2017 |
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

if you want to print out a variable that's initiated inside a loop you won't be able to do it because of the variables scope so just start it outside any loop and the scope of that variable is from where ever that variable was initiated all the way to the end of the main method

jgarc629
Posts: 76
Posted 02:49 Mar 19, 2017 |
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

if you want to print out a variable that's initiated inside a loop you won't be able to do it because of the variables scope so just start it outside any loop and the scope of that variable is from where ever that variable was initiated all the way to the end of the main method

I used an accummilator which helped, but how can I get the index of vowels?

jzunig20
Posts: 38
Posted 02:54 Mar 19, 2017 |
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

if you want to print out a variable that's initiated inside a loop you won't be able to do it because of the variables scope so just start it outside any loop and the scope of that variable is from where ever that variable was initiated all the way to the end of the main method

I used an accummilator which helped, but how can I get the index of vowels?

you're checking every single character to see whether its a vowel or not, so you start from 0 right,

int vowelIndex = stringname.charAt(variable);

the variable thats allowing you to check each character should be the index just find out which index it is

jgarc629
Posts: 76
Posted 12:34 Mar 19, 2017 |
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

if you want to print out a variable that's initiated inside a loop you won't be able to do it because of the variables scope so just start it outside any loop and the scope of that variable is from where ever that variable was initiated all the way to the end of the main method

I used an accummilator which helped, but how can I get the index of vowels?

you're checking every single character to see whether its a vowel or not, so you start from 0 right,

int vowelIndex = stringname.charAt(variable);

the variable thats allowing you to check each character should be the index just find out which index it is

How do you save it with the accumelator tho? Do you still use += and the empty string? Because I think I'm getting the sum of it instead of just the numbers 

jzunig20
Posts: 38
Posted 12:40 Mar 19, 2017 |
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

if you want to print out a variable that's initiated inside a loop you won't be able to do it because of the variables scope so just start it outside any loop and the scope of that variable is from where ever that variable was initiated all the way to the end of the main method

I used an accummilator which helped, but how can I get the index of vowels?

you're checking every single character to see whether its a vowel or not, so you start from 0 right,

int vowelIndex = stringname.charAt(variable);

the variable thats allowing you to check each character should be the index just find out which index it is

How do you save it with the accumelator tho? Do you still use += and the empty string? Because I think I'm getting the sum of it instead of just the numbers 

the same way you solved the hw problem in hw07p05 where you go from decimal to binary, you're putting 1's and 0's together, those are numbers, except this time you're just adding a space so they won't be together like the 1's and 0's in a binary number

jgarc629
Posts: 76
Posted 13:32 Mar 19, 2017 |
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:
jzunig20 wrote:
jgarc629 wrote:

I think I know what to do to skip the letter if it is a vowel, but how do I add the underscore? I saw in another post about this problem that you are gonna have to create another string? Any other hints for the underscores?

normally to get the characters which are not vowels, you're just adding the char you're checking back into it so,

if the char you're checking is a vowel, add an underscore that time,

otherwise, add the regular char

I figured it out but idk how to write out the solution without breaking the scope of a variable 

if you want to print out a variable that's initiated inside a loop you won't be able to do it because of the variables scope so just start it outside any loop and the scope of that variable is from where ever that variable was initiated all the way to the end of the main method

I used an accummilator which helped, but how can I get the index of vowels?

you're checking every single character to see whether its a vowel or not, so you start from 0 right,

int vowelIndex = stringname.charAt(variable);

the variable thats allowing you to check each character should be the index just find out which index it is

How do you save it with the accumelator tho? Do you still use += and the empty string? Because I think I'm getting the sum of it instead of just the numbers 

the same way you solved the hw problem in hw07p05 where you go from decimal to binary, you're putting 1's and 0's together, those are numbers, except this time you're just adding a space so they won't be together like the 1's and 0's in a binary number

Okay I figured out the problem, I had to use another empty string to add to variable.indexof(vowel) since it was an int in order to keep it as a string when I use +=. Program is up and running, thanks dude!