subject

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

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
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 10:30
How would you categorize the software that runs on mobile devices? break down these apps into at least three basic categories and give an example of each.
Answers: 1
question
Computers and Technology, 24.06.2019 07:30
Consider the folloeing website url: what does the "http: //" represent? a. protocal identifier. b. ftp. c. domain name d. resource name
Answers: 2
You know the right answer?
import java. util. Scanner; import java. util. StringTokenizer; public class ICE2 { public static vo...
Questions
question
Spanish, 09.03.2021 17:50
question
English, 09.03.2021 17:50
Questions on the website: 13722360