public String shorthand(String in)
Posted
by luvthug
on Stack Overflow
See other posts from Stack Overflow
or by luvthug
Published on 2010-05-03T19:52:08Z
Indexed on
2010/05/03
19:58 UTC
Read the original article
Hit count: 130
java
Hi All,
I am stuck on this code.
The code should use the class StringBuilder to build an output string by appending non-vowel characters from its argument in to the result it returns. It needs to identify vowels to be removed using the helper metod i created which is public boolean isVowel(char c).
public String shorthand(String in) this is the method I need help with. I have created the stringbuilder but the if condition does not accept isVowel method.
import java.io.*;
import java.util.*;
public class Shorthand
{
public boolean isVowel(char c)
{
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A'|| c == 'E'||c == 'I'|| c == 'O'|| c == 'U')
{
return true;
}
else
{
return false;
}
}
//TODO Complete the shorthand method
public String shorthand(String in) //this is the code I need help with
{
StringBuilder vowel = new StringBuilder();
if (isVowel() == false)strong text
{
vowel.append(in);
}
return vowel.toString();
}
//TODO Complete the run method
public void run() throws IOException
{
String yourLine;
Scanner sc = new Scanner(System.in);
yourLine = sc.nextLine();
while(!yourLine.equals("*"));
{
System.out.println("Enter your line of text");
}
yourLine = sc.nextLine();
}
}
© Stack Overflow or respective owner