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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:00, littleprinces
Your task this week is to write a very simple spam classifier in python. it will classify messages as either spam (unwanted) or ham (wanted). the program will have a set of spam_words, words that are known to appear in spam messages. that set is included in the template file spam. pypreview the document. you will also define a spam threshold which reflects the allowed percentage of spam words in the message. you'll compute a 'spam indicator', which is the ratio of spam words to the total number of unique words in the message. if the spam indicator exceeds the spam threshold, the message is classified as spam. otherwise it is classified as ham. we'll assume that the spam threshold is a constant and has a value of 0.10. your program will prompt the user for a message and then will print the corresponding spam indicator with two decimal digits and the corresponding classification (spam or ham). the program will be case insensitive. the spam words are detected whether they are in lower case or upper case or mixed case. each word, spam or not, is counted once (even if it appears multiple times in the message.) the program will remove punctuation from the message before identifying the words and computing the spam indicator. for example '! ' must be identified as the spam word 'now'.
Answers: 3
image
Computers and Technology, 23.06.2019 09:10, djs1671
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, Princessirisperez0
Given a link with a maximum transmission rate of 32.8 mbps. only two computers, x and y, wish to transmit starting at time t = 0 seconds. computer x sends filex (4 mib) and computer y sends filey (244 kib), both starting at time t = 0. statistical multiplexing is used, with details as follows packet payload size = 1000 bytes packet header size = 24 bytes (overhead) ignore processing and queueing delays assume partial packets (packets consisting of less than 1000 bytes of data) are padded so that they are the same size as full packets. assume continuous alternating-packet transmission. computer x gets the transmission medium first. at what time (t = ? ) would filey finish transmitting? give answer in milliseconds, without units, and round to one decimal places (e. g. for an answer of 0.013777 seconds you would enter "13.8" without the quotes)
Answers: 3
image
Computers and Technology, 23.06.2019 11:30, kyraj21
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1
You know the right answer?
/*
(count vowels and consonants) assume letters a, e, i, o, and u as the vowels.
write a...

Questions in other subjects:

Konu
Mathematics, 06.07.2019 18:00