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 00:30
Which of the following methods could be considered a “best practice” in terms of informing respondents how their answers to an on-line survey about personal information will be protected? respondents are informed that investigators will try to keep their participation confidential; however, confidentiality cannot be assured. respondents are informed that a research assistant will transfer all the research data to a password-protected computer that is not connected to the internet, via a usb flashdrive. the computer is located in a research team member’s office. the investigator uses the informed consent process to explain her institution’s method for guaranteeing absolute confidentiality of research data. the investigator uses the informed consent process to explain how respondent data will be transmitted from the website to his encrypted database without ever recording respondents’ ip addresses, but explains that on the internet confidentiality cannot be absolutely guaranteed.
Answers: 1
question
Computers and Technology, 22.06.2019 17:20
[a] create a class called “cycle” which has two instance integer variables as properties, “numberofwheels” and “weight.” create a constructor with two parameters, using the same variable names in the parameter list. assign each variable to numberofwheels” and “weight” respectively. write a separate application to test the class and display its properties. note: do not change the names of the instance variables or the variables listed in the constructor’s parameter list. [b] edit your class cycle by adding a default constructor which will assign the default values of 100 to represent the numberofwheels, and 1000 to represent the weight, by invoking a call to the other constructor. modify your application created in [a] to test the class.
Answers: 3
question
Computers and Technology, 23.06.2019 13:00
Donnie does not have powerpoint. which method would be best for elana to save and share her presentation as is? a pdf a doc an rtf a ppt
Answers: 3
question
Computers and Technology, 23.06.2019 22:20
What is a programming method that provides for interactive modules to a website?
Answers: 1
You know the right answer?
import java. util. Scanner; import java. util. StringTokenizer; public class ICE2 { public static vo...
Questions
question
Mathematics, 03.12.2021 18:10
question
Mathematics, 03.12.2021 18:10
question
Mathematics, 03.12.2021 18:10
Questions on the website: 13722363