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
Which of the following is NOT a type of insurance fraud?
inessss [21]

Answer:

Arson

Explanation:

Because arson is setting something on fire on purpose to cause damage.

The others all are some form or another of insurance fraud.

8 0
3 years ago
Read 2 more answers
Only one person can receive the same email at the same time true or false
nasty-shy [4]

Answer:

false

Explanation:

5 0
3 years ago
Did the Z3 computer invented by Konrad Zuse have a negative effect on society?
musickatia [10]

Answer:

Explanation:

Không

4 0
2 years ago
Read 2 more answers
The HTML tag for the smallest heading is​ what​
Gre4nikov [31]

Answer:

The HTML <h1> to <h6> tag is used to define headings in an HTML document. <h1> defines largest heading and <h6> defines smallest heading.

Explanation:

5 0
3 years ago
How long is the bachelor's program at Eth Zurich? 3 or 4 years?
natulia [17]
The bachelor's program at Eth Zurich is 3 years.
I hope this helps!
:-)
4 0
3 years ago
Other questions:
  • Rori is looking for a way to interact with others while increasing her stamina. Which community resource would be least helpful
    13·1 answer
  • If I put a short clip from a copyrighted video to Facebook and make it only viewable to friends, is that illegal?
    12·1 answer
  • Frank is a writer. He needs to work for long hours and type for long periods on the computer. What injury can Frank develop?
    15·2 answers
  • A web browser allows you to manage computer files and programs true false
    15·1 answer
  • Controlling the physical world with sensors and digital devices depends on bandwidth and the ability to analyze data in real tim
    5·1 answer
  • What happens when two computers have the same IP address?
    13·1 answer
  • The correct ordering of the seven layers from "top" to "bottom" is
    11·1 answer
  • Which of the following is true of a procedure? Check all that apply.
    10·2 answers
  • The most important hardware device for connecting supercomputers over a wide area
    10·1 answer
  • "You have created a Word document named apple.docx using Microsoft Word. What type of a file is apple.docx ? Select all that app
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!