3 Replies - 298 Views - Last Post: 08 February 2018 - 05:53 AM Rate Topic: -----

#1 Xhertus  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 03-February 18

Determine a letter is vowel or not

Posted 08 February 2018 - 03:58 AM

public String doubleVowel(String str)
{
    String result ="";
    for(int i =0; i < str.length(); i++)
    {
        
        if(isVowel)
        {
            result+ = str.charAt(i);
        }
        
        result+ = str.charAt(i);    
     }
}

private boolean isVowel(char letter)
{
    if(letter = 'a')
    {
        return true;
    }
    if(letter = 'e')
    {
        return true;
    }
    if(letter = 'u')
    {
        return true;
    }
    if(letter = 'i')
    {
        return true;
    }
    if(letter = 'o')
    {
        return true;
    }
}




Hello, I talked about that method before. I want to writee a method which just doubles the vowels. I written like that, I got illegal start of expression mistakes at lines 9 an 12. Waiting for some advice.

Is This A Good Question/Topic? 0
  • +

Replies To: Determine a letter is vowel or not

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3504
  • View blog
  • Posts: 15,846
  • Joined: 20-September 08

Re: Determine a letter is vowel or not

Posted 08 February 2018 - 04:14 AM

+= is a single operator with no spaces in it
Was This Post Helpful? 0
  • +
  • -

#3 Thomas1965  Icon User is offline

  • D.I.C Regular

Reputation: 82
  • View blog
  • Posts: 323
  • Joined: 09-September 16

Re: Determine a letter is vowel or not

Posted 08 February 2018 - 04:50 AM

= is the assignment operator, == the comparison operator, so your isVowel function won't work
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3504
  • View blog
  • Posts: 15,846
  • Joined: 20-September 08

Re: Determine a letter is vowel or not

Posted 08 February 2018 - 05:53 AM

return "aeiou".indexOf(letter) >= 0;

could be the entire body of that method
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1