Computers and Technology

/*
(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);
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:30, dpazmembreno
Ajeweler designing a pin has decided to use five stones chosen from diamonds, rubies, and emeralds. in how many ways can the stones be selected?
Answers: 3
image
Computers and Technology, 22.06.2019 09:30, caldonjoshhsms2061
What are the steps involved in accepting all the changes in a document? arrange these in order click edit. click accept or reject. click changes. click accept all.
Answers: 1
image
Computers and Technology, 22.06.2019 17:40, pnhandley01
Consider the simple 3-station assembly line illustrated below, where the 2 machines at station 1 are parallel, i. e., the product only needs to go through one of the 2 machines before proceeding to station 2.what is the throughput time of this process?
Answers: 2
image
Computers and Technology, 22.06.2019 18:30, leannhb3162
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
Do you know the correct answer?
/*
(count vowels and consonants) assume letters a, e, i, o, and u as the vowels.
write a...

Questions in other subjects:

Konu
Business, 04.02.2021 08:40
Konu
Chemistry, 04.02.2021 08:40
Konu
Mathematics, 04.02.2021 08:40