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
90 POINTS Hazel is working with a database to help determine if the company she works for is making or losing money. Hazel has o
VikaD [51]

Answer:

a

Explanation:

5 0
2 years ago
Read 2 more answers
¿En cuales situaciones concretas se puede aplicar las técnicas de conteo(particularmente las permutuaciones y las combinaciones)
Andrei [34K]

Answer:

In which specific situations can counting techniques (particularly permutuations and combinations) be applied within computer science? for anybody trying to help

7 0
3 years ago
Which of the following are incorrect safety precautions for equipment operators? A. Drive equipment or vehicles on grades or roa
Zarrin [17]
Hello!

The correct answer would be: D. Should not exceed a vehicle's rated load or life capacity.

I hope you found this helpful! :)
3 0
3 years ago
Read 2 more answers
Do you know how to change your grades on a printer???????????
BabaBlast [244]

Answer:

To change ur grade make sure to do it on the website first by right clicking your mouse and clicking inspect element and once done changing x out and it will save

Explanation:

5 0
2 years ago
Explain how a touris could use QR codes at an airport to help plan a holiday
elena55 [62]

Answer:

with tech

Explanation:

8 0
3 years ago
Other questions:
  • Which element of a business document provides additional information but is not a part of the body of the text?
    13·2 answers
  • Class CTRivers describes collection of CT rivers. It has no data, and it provides the following service methods. None of the met
    13·1 answer
  • Select the statements that are true regarding the future of technology. Select 2 options.
    10·2 answers
  • What is meant by polling mode in communication between software andUART and what is its disadvantage as compared to interrupt mo
    14·1 answer
  • While designing your network's VLAN topology, your team has decided to use a centrally managed DHCP server rather than creating
    8·1 answer
  • Letter Frequency Write a function that will take a string and return a count of each letter in the string. For example, "my dog
    5·1 answer
  • Please help! 40 points + Brainliest!
    8·1 answer
  • What is a Hard Drive
    13·1 answer
  • Consider the method get Hours, which is intended to calculate the number of hours that a vehicle takes to travel between two mil
    6·1 answer
  • Briefly describe the working of computer processing system?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!