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
Allison needs to graph the yearly average snowfall in Alaska. She should use a:
bazaltina [42]

C: bar graph

bar graphs are used to track changes over time, so I would say that C is your best bet

7 0
4 years ago
Read 2 more answers
What is the recommended procedure for disconnecting an external hard drive to avoid losing data??
SpyIntel [72]
Go to files than click on USB file then do eject device before taking it out
6 0
3 years ago
Read 2 more answers
Relational operators allow you to ________ numbers
Sonja [21]

Relational operators allow an end user to <u>compare</u> numbers.

<h3>What are relational operators?</h3>

Relational operators can be defined as a programming language construct which allows an end user to compare both numbers and char values.

Also, it can be used to determine whether one number is less than (<), greater than (>), equal to (=), or not equal to another.

This ultimately implies that, relational operators allow an end user to <u>compare</u> numbers.

Read more on relational operators here: brainly.com/question/14995818

#SPJ1

6 0
2 years ago
Match the cell reference to its definition,
Anna35 [415]

Answer:

Absolute reference- the cell remains constant when copied or moved

Relative reference- the cell changes based on the position of rows and columns

Mixed references- the cell has combination of two other types of cell references

Explanation:

4 0
2 years ago
FAST ANSWER I NEED FOR APEX NOW!!!!!!!!!!!!!!!
yawa3891 [41]
I think the answer is A. The classroom is a place for learning not for making phone calls
8 0
3 years ago
Read 2 more answers
Other questions:
  • Design the below using an array// Sunrise Freight charges standard// per-pound shipping prices to the five states they serve// –
    6·1 answer
  • When first created all charts always include___and a chart area
    8·2 answers
  • The picture that graphically represents the items you use in windows is called a/an
    15·2 answers
  • Preesure is drived quantity? why​
    15·2 answers
  • Match the fallacy with its name. Being a speaker of Spanish, I'm also great at speaking Italian.
    10·1 answer
  • How is a computer and a iphone different
    9·1 answer
  • Explicit knowledge can be documented and codified, whereas tacit knowledge encompasses insights, judgment, creative processes, a
    9·1 answer
  • Which of the following entries into the username and password fields will NOT cause us to gain admin access? You may assume that
    12·1 answer
  • 4. What is the package name in which the Scanner class resides?
    14·1 answer
  • Why does this happen to me?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!