Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA PLEASE Write a class called StringClassifier that displays information about the keystrokes in a string. The class should have the following members: The
IN JAVA PLEASE
Write a class called StringClassifier that displays information about the keystrokes in a string. The class should have the following members: The string attribute will contain a string value. It can be anything - numbers, letters, or special characters. fa In the mutator method, the string attribute is only set if there are characters in the programmer-supplied string. The letters and digits attributes will store the number of letters and digits in the string. The uppers and lowers attributes will each store the number of upper-case and lowercase letters in the string. The evens and odds attributes will each store the number of even digits and odd digits in the string. None of these data members require accessor/mutator methods, since they will be given their values in the classify() method, and their values can be viewed in the toString() method. The classify() method will examine the string attribute and store the following information in the other instance variables: The classify() method will examine the string attribute and store the following information in the other instance variables: - The number of keystrokes in the string. - The number of letters in the string. - The number of upper-case and lower-case letters in the string. - The number of digits in the string. - The number of even and odd digits in the string. The toString () method will return a string that shows the information about your string (see sample code and screen shots below for format). The following program can be used to test your class: import javax. swing. JOptionPane; public class Testclassifier \{ public static void main (String[] args) \{ String str = JOptionPane.showInputDialog(null, "Enter a sentence to classify.", "Sentence Input", JOptionPane.QUESTION MESSAGE); Stringclassifier classifier = new StringClassifier (str); JOptionPane. showMessageDialog (null, classifier.toString(), "String Information", JOptionPane. INFORMATION MESSAGE); 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started