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
Liono4ka [1.6K]
3 years ago
9

Write a function called count_vowels that accepts a string argument that represents a word and returns the number of vowels that

are in the word. The vowels are A, E, I, O, and U (ignore the 'sometimes Y' rule). Count both uppercase and lowercase vowels.
Computers and Technology
1 answer:
stellarik [79]3 years ago
3 0

Answer:

public static int count_vowels(String str){

       String word = str.replaceAll("[^a-zA-Z0-9]", "");

       String text = word.toUpperCase();

       int lenOfString = text.length();

       int count =0;

       for(int i =0; i<lenOfString; i++){

           if(text.charAt(i)=='A'||text.charAt(i)=='E'||text.charAt(i)=='I'

                   ||text.charAt(i)=='O'||text.charAt(i)=='U'){

               count++;

           }

       }

       return count;

   }

Explanation:

This has been implemented using Java programming language.

Firstly, white spaces, special characters and punctions are removed from the string uisng the replaceAll() method

The string is converted to all upper cases

a for loop is used to count the number of vowels and store to a variable count

In the main method a call to count_vowels is done

<em>public class num1 {</em>

<em>    public static void main(String[] args) {</em>

<em>        String name = "David %$ !. gjak";</em>

<em>        System.out.println("The number of vowels in "+name+ " are "+count_vowels(name));</em>

<em>    }</em>

<em>    public static int count_vowels(String str){</em>

<em>        String word = str.replaceAll("[^a-zA-Z0-9]", "");</em>

<em>        String text = word.toUpperCase();</em>

<em>        int lenOfString = text.length();</em>

<em>        int count =0;</em>

<em>        for(int i =0; i<lenOfString; i++){</em>

<em>            if(text.charAt(i)=='A'||text.charAt(i)=='E'||text.charAt(i)=='I'</em>

<em>                    ||text.charAt(i)=='O'||text.charAt(i)=='U'){</em>

<em>                count++;</em>

<em>            }</em>

<em>        }</em>

<em>        return count;</em>

<em>    }</em>

<em>}</em>

<em />

The complete program with a Main method is given below

You might be interested in
Which tasks can Kim complete using the Customize Ribbon dialog box? Check all that apply.
exis [7]

Answer:

Its A, B, C, and F

Explanation:

On edg

5 0
3 years ago
Question 1 (True/False Worth 15 points)
liraira [26]

It is a programmer's responsibility to contribute to society and human well-being is true.

Explanation:

  • It is a programmer's responsibility to contribute to society and human well-being is true.
  • The Association for Computing Machinery (ACM) is known as  the world's largest educational and scientific computing society.
  • It has its own Code of Ethics and another set of ethical principles which were also approved by the IEEE as the known standards of teaching and practicing software engineering.
  • Programmers contribute to develop computer systems which can reduce negative impression to the society.
  • The negativity includes as threats to safety and health, which can be reduced and make everyday activities and work easier.
  • software developers should reduce the risk of harming others due to the coding errors or the security issues which could impact human well-being.

3 0
3 years ago
How does technology influence the development of personal and public identity?
Marysya12 [62]

Answer:

Technology affects the way individuals communicate, learn, and think. It helps society and determines how people interact with each other on a daily basis. Technology plays an important role in society today. It has positive and negative effects on the world and it impacts daily lives.

Hope it's helpful to u

6 0
3 years ago
PLEASE HELP ASAP!!
inn [45]
The answer is encryption

steganography would be hiding data, like in an image
digital forensics is the analysis done after an attack
and the last one is a security standard
6 0
3 years ago
On a wireless router, what gives out IP addresses?<br> DHCP<br> DNS<br> WPA<br> WPS
attashe74 [19]

Answer:

DHCP

Explanation:

The only option can give IP addresses is the DHCP The Dynamic Host Configuration Protocol, because the DNS (Domain Name System) only translates IP addresses to a hostname, and WPS (Wi-Fi Protected Setup) or WPA (Wi-Fi Protected Access) if for security network, doesn't matter if is a wireless router, in a network always DHCP gives the IP addresses.

7 0
3 years ago
Other questions:
  • Which loan type requires you to make loan payments while you’re attending school?
    9·1 answer
  • The Security Development Life Cycle (SDLC) is a general methodology for the design and implementation of an information system.
    5·1 answer
  • Access Control can be defined as putting controls (or countermeasures) in place to help achieve information security goals. Whic
    13·2 answers
  • There are three types of value for money. Which of the following is not a method of value?
    14·1 answer
  • Write a void method named myMethod which prints "This is a void method" (without the quotes). Your method should be declared pub
    5·1 answer
  • What are benefits of virtualizing servers ?
    5·1 answer
  • Microsoft word 2010 lab 6-1
    7·2 answers
  • The WordPress Widgets submenu is located where on the WordPress site?
    5·1 answer
  • Is y0utube an example of unsupervised learning or supervised learning?
    13·1 answer
  • Think about all the different ways you communicate with other people throughout your day. • What makes this communication succes
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!