subject

/*
(count vowels and consonants) assume letters a, e, i, o, and u as the vowels.
write a program that prompts the user to enter a string and displays the number
of vowels and consonants in the string.
*/
import java. util. scanner;

public class exercise_05_49 {
public static void main(string[] args) {
scanner input = new scanner(system. in);

// prompt the user to enter a string
system. out. print("enter a string: ");
string string = input. nextline();

int vowels, // count the number of vowels
consonants; // count the number of consonants
vowels = consonants = 0; // initialize accumulators to 0

// count the number of vowels and consonants
for (int i = 0; i < string. length(); i++) {
if (character. isletter(string. charat( {
if (character. touppercase(string. charat(i)) == 'a' ||
character. touppercase(string. charat(i)) == 'e' ||
character. touppercase(string. charat(i)) == 'i' ||
character. touppercase(string. charat(i)) == 'o' ||
character. touppercase(string. charat(i)) == 'u') {
vowels++;
}
else
consonants++;
}

// display results
system. out. println("the number of vowels is " + vowels);
system. out. println("the number of consonants is " + consonants);
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
The “rule of 72” is used to approximate the time required for prices to double due to inflation. if the inflation rate is r%, then the rule of 72 estimates that prices will double in 72/r years. for instance, at an inflation rate of 6%, prices double in about 72/6 or 12 years. write a program to test the accuracy of this rule. for each interest rate from 1% to 20%, the program should display the rounded value of 72/r and the actual number of years required for prices to double at an r% inflation rate. (assume prices increase at the end of each year.)
Answers: 1
question
Computers and Technology, 23.06.2019 00:00
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. a company is currently focusing on creating specific management goals for itself. which level of maturity is the company demonstrating under the sse_ccm framework? a. performed informally b. planned and tracked c. quantitatively controlled d. well-defined e. continuously improving
Answers: 2
question
Computers and Technology, 24.06.2019 00:40
What social factors affect your health
Answers: 3
You know the right answer?
/*
(count vowels and consonants) assume letters a, e, i, o, and u as the vowels.
write a...
Questions
question
Mathematics, 16.04.2021 14:00
question
Mathematics, 16.04.2021 14:00
question
Mathematics, 16.04.2021 14:00
Questions on the website: 13722361