1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Wewaii [24]
3 years ago
14

#Write a function called has_a_vowel. has_a_vowel should have #one parameter, a string. It should return True if the string #has

any vowels in it, False if it does not.
Computers and Technology
1 answer:
Vladimir [108]3 years ago
8 0

Answer:

Here is code in java.

import java.util.*;

class Main

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // scanner object to read input from user

       Scanner obj=new Scanner(System.in);

       System.out.println("please enter a string:");

       //read the string input

       String inp=obj.next();

       // call the function to check whether string has vowel or not

       Boolean res=has_a_vowel(inp);

       // printing the result

       System.out.println("string contains vowel."+res);

     

       

   }catch(Exception ex){

       return;}

}

 // method to check string has vowel or not

public static boolean has_a_vowel(String str)

{

 // find length of the string

    int len=str.length();

   

    Boolean flag=false;

     int i;

    for( i=0;i<len;i++)

    {

        char chh=str.charAt(i);

         // if string contains vowel then flag will be true

        if(chh=='a'||chh=='e'||chh=='i'||chh=='o'||chh=='u')

        {

            flag=true;

            break;

        }

    }

     //returning the result

    return flag;

}

}

Explanation:

Create a scanner class object to read the string and assign it to variable

"inp".Call the function "has_a_vowel" with a string parameter.In this function

find the length of string and travers the string.If there is any vowel character

in the string then flag will be set to true otherwise flag will be false. Then it will

return the value of flag.We can test the function from the main by passing a string parameter.

Output:

please enter a string:                                                                                                                                        

vjcavcavacvajjfd                                                                                                                                              

string contains vowel:true

please enter a string:                                                                                                                                        

sdfdhgjkhltyrqwzxcvbmm                                                                                                                                        

string contains vowel: false                                                                                                                                  

                             

You might be interested in
How many digits are in the binary number system? Explain why.
Katen [24]

Answer:

Since there are only two digits in binary, there are only two possible outcomes of each partial multiplication: If the digit in B is 0, the partial product is also 0. If the digit in B is 1, the partial product is equal to A.

Explanation:

8 0
2 years ago
Read 2 more answers
Well I am having trouble and I feel really bad because I helped RandomGuy1 who rubs it in my face that I gave him the wrong answ
yawa3891 [41]
Hey dude don't leave tell a mod bout it they'll fix everything up for you.
8 0
3 years ago
Which is the most visual social media site?
Aleks04 [339]
Enge extrapolated this analysis across the 2.2 billion<span> users on Google and concluded that while the “active profiles” on Google+ amount to </span>111 million<span> users, only 6.7 million users have 50 or more posts ever, and only 3.5 million have 50 or more posts in the last 30 days</span>
3 0
3 years ago
Which of the following actions is most likely to raise legal or ethical concerns?
zavuch27 [327]

Answer:

arson, kidnapping, gun fighting

Explanation:

7 0
2 years ago
Read 2 more answers
Black and white squares codehs, i need the whole code (40 points for correct answer)
ludmilkaskok [199]

Answer:

speed(0)

penup()

setposition(-100,0)

count=0

def make_squares(i):

if i % 2 == 0:

begin_fill()

for i in range(4):

forward(25);

left(90)

end_fill()

penup()

pendown()

for i in range(6):

pendown()

make_squares(i)

penup()

forward(35)

Explanation:

3 0
2 years ago
Read 2 more answers
Other questions:
  • _____________ is a service that provides access to hardware resources available over the Internet.
    11·1 answer
  • Abram was asked to explain to one of his coworkers the XOR cipher. He showed his coworker an example of adding two bits, 1 and 1
    7·1 answer
  • Design a new Triangle class that extends the abstract
    13·1 answer
  • At the moment i am tackling the cs50x projects and i need a little bit of help with problem set 1, the 'greedy algorithm'. I am
    5·1 answer
  • What development in operating systems happened between the years 1990 and 2000?
    15·1 answer
  • . Write a swift programming code to perform following tasks a) Declare a variable that stores the age of a person b) Declare a c
    5·1 answer
  • what are the benefits of VolP? select all that apply. A:cheaper printings B:clearer calls C: faster download D: increased effici
    11·2 answers
  • Which magazine introduced the first microcomputer kit for the mits altair in its january 1975 issue?
    8·1 answer
  • In the value chain concept, upgrading IT is considered what kind of activity?
    9·1 answer
  • Which steps of the management science process can either be a recommended decision or information that helps a manager a decisio
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!