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 12:10
1. declare a constant named cents_per_pound and initialize with 25. 2. get the shipping weight from user input storing the weight into shipweightpounds. 3. using flat_fee_cents and cents_per_pound constants, assign shipcostcents with the cost of shipping a package weighing shipweightpounds.
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
How do you share someone else’s tweet with your own twitter followers?
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Think of a spreadsheet as a giant calculator spread of paper chart data collector
Answers: 2
question
Computers and Technology, 25.06.2019 05:10
Assume that two parallel arrays have been declared and initialized: healthoption an array of type char that contains letter codes for different healthcare options and annual cost an array of type int. the i-th element of annual cost indicates the annual cost of the i-th element of healthoption. in addition, there is an char variable, best2.write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. thus, if the values of healthoption are 'b', 'q', 'w', 'z' and the values of annualcost are 8430, 9400, 7050, 6400 your code would assign 'b' to best2 because 8430 is less than 9400 and is associated with 'b' in the parallel array. (we ignore 'w' and 'z' because we are considering only the first two options.)
Answers: 1
You know the right answer?
import java. util. Scanner; import java. util. StringTokenizer; public class ICE2 { public static vo...
Questions
question
Arts, 12.11.2020 02:50
question
English, 12.11.2020 02:50
question
Mathematics, 12.11.2020 02:50
question
Mathematics, 12.11.2020 02:50
question
Mathematics, 12.11.2020 02:50
Questions on the website: 13722361