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
Assoli18 [71]
3 years ago
15

Write a function that takes in input an English Sentence and prints the total number of vowels and the total number of consonant

s in the sentence. The function returns nothing. Note the sentence could have special characters like: whitespaces, punctuation marks and numbers.
Computers and Technology
1 answer:
Galina-37 [17]3 years ago
5 0

Answer:

public static void vowelsConsonantCount(String str){

       String text = str.toLowerCase();

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

       int lenWord = word.length();

       int count = 0;

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

           if(word.charAt(i)=='a'||word.charAt(i)=='e'||word.charAt(i)=='i'

                   ||word.charAt(i)=='o'||word.charAt(i)=='u'){

               count++;

           }

       }

       int consonants = lenWord-count;

       System.out.println("the total vowels are "+count);

       System.out.println("The total consonants are: "+consonants);

   }

Explanation:

  • In Java programming language
  • The method uses java's replaceAll() method to remove all spaces and special characters and punctuations.
  • It converts the string entered into all lower cases using toLowerCase() method
  • Calculates the length of the resulting string using the length() method
  • Using if statement the total vowels are counted, subtracting the total vowels from the size of the string gives the total consonants
  • These two values are outputed.
You might be interested in
Security administrator for your organization utilized a heuristic system to detect an anomaly in a desktop computer's baseline.
Helen [10]

Answer:

Zero day

Explanation:

Zero day attack is the term used to describe the threat of an unknown security vulnerability in a computer software or application for which either the patch has not been released or the application developers were unaware of or did not have sufficient time to address.

Since the vulnerability is not known in advance, the exploits often occur without the knowledge of the users. A zero day flaw is considered as an important component when designing an application to be efficient and secure.

3 0
4 years ago
Susan has always wanted to be a veterinarian. When doing her research, she answers all self-assessments geared toward that caree
kherson [118]
She should be researching every component towards a veterinarian
5 0
3 years ago
Describe the different non-printing characters,​
irakobra [83]

Answer:

or formatting marks are characters for content designing in word processors, which aren't displayed at printing. It is also possible to customize their display on the monitor. The most common non-printable characters in word processors are pilcrow, space, non-breaking space, tab character etc.

Explanation:

5 0
3 years ago
Which situation is an example of? "relational context" in the transactional model of? communication?
Jlenok [28]
An example I believe of relational context is when I was out with my son on the weekend (he has a developmental disability) and we had agree I would buy him a 1/2 sub sandwich the day before but then he said I would like a McFlurry so I said okay and then he said so you mean I can have a McFlurry and a sub and I thought oh oh I stuck my foot in it so I said but it must be only a 1/2 sub so he said no I want a full sub then and no mcflurry so I agreed so from the original 1/2 sub idea the idea evolved to a full sub which was affected by the warm sunny summery weather in the afternoon and seeing people lined up at ice cream shops so the idea developed in relation to the weather, how hungry he was and the social aspect people buying ice cream.
8 0
3 years ago
Help me please, I'm attempting a test<br>​
dusya [7]
It’s A it’s a keyboard
8 0
3 years ago
Read 2 more answers
Other questions:
  • According to Mintzberg's classification of managerial roles, the role of a(n) ______ is to transmit information received from ou
    7·1 answer
  • The factorial of an integer N is the product of the integers between 1 and N, inclusive. Write a while loop that computes the fa
    10·1 answer
  • Crop marks are used on an illustration to indicate to the printer the
    10·1 answer
  • Consider the following constructor for an immutable matrix ADT:
    8·1 answer
  • After compiling source code, which command still needs to be run in order to copy the newly compiled binaries into a directory l
    5·1 answer
  • What is not an option when a user is exporting contacts to share with others?
    10·1 answer
  • ____ is the only automated disk-to-disk tool that allows you to copy data to a slightly smaller target drive than the original s
    5·1 answer
  • True or false: when an ospf route sends its link state information, it is sent only to those nodes directly attached neighbors.
    14·1 answer
  • Lin wants to play an online game with her friends. She read the description of the game and knows it contains several features w
    12·1 answer
  • Question 1 (1 point)
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!