Computers and Technology

import java. util. Scanner; import java. util. StringTokenizer; public class ICE2 { public static void main(String[] args) { // Ask user for a sentence int n = 5; String sentence; StringTokenizer tokens; Scanner keyboard = new Scanner(System. in); System. out. println("Enter a sentence"); //Use string tokenizer to split up the input into tokens StringTokenizer tokenizer = new StringTokenizer(sentence); n = tokenizer. countTokens(); //check how many tokens if(n < 5) { System. out. println("Enter more words."); } if(n > 8) { System. out. println("Enter less words."); } while(n-->0) { //Display the entire sentence System. out. println(sentence); while(tokens. hasMoreTokens()) { //get token String token = tokens. nextToken(); int letters = 0; int digits = 0; int uppercase = 0; int lowercase = 0; int space = 0; String t = tokens. nextToken();{ for(int i = 0; i < token. length(); i++) { char ch = token. charAt(i); if(Character. isLetter(ch)) { letters++; } if(Character. isDigit(ch)) { digits++; } if(Character. isUpperCase(ch)) { uppercase++; } if(Character. isLowerCase(ch)) { lowercase++; } if(Character. isSpaceChar(ch)) { space++; } System. out. println(t + ":" + t. length()); } String nospace = sentence. replace(" ", ""); System. out. println("The total number of characters excluding the spaces." + nospace. length()); } } } } }

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 21:00, htahir2345
You turn your computer on and the computer will not boot up where is something you should do to diagnose the problem?
Answers: 1
image
Computers and Technology, 23.06.2019 00:30, lm18618
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
image
Computers and Technology, 23.06.2019 21:40, jeovontamarley
language consists of basic components, and they are called a. 3; mental images, concepts, and speech b. 2; language acquisition and linguistic relativity c. 3; heuristics, algorithms, and analogies d. 4; phonemes, morphemes, syntax, and semantics e. 2; words and grammar
Answers: 3
image
Computers and Technology, 23.06.2019 22:50, atifgujar
An environmental protection agency study of 12 automobiles revealed a correlation of 0.47 between engine size and emissions. at 0.01 significance level, can we conclude that there is a positive association between the variables? what is the p value? interpret.
Answers: 2
Do you know the correct answer?
import java. util. Scanner; import java. util. StringTokenizer; public class ICE2 { public static vo...

Questions in other subjects: