Question: Figure 3 : Sample output The class contains several private attributes: str stores the sentence input byuser. specialChars stores number of special characters ( i

Figure 3: Sample output
The class contains several private attributes:
str stores the sentence input byuser.
specialChars stores number of special characters (i.e. non-digit and non-letters:
;-!@ etc) in the input string.
digits stores the number of digits (e.g.0,1,2,etc) in the input string.
uppers stores the number of upper-case letters (e.g. A, B, C, etc.) in the input string.
lowers stores the number of lower-case letters (e.g. a, b, c etc.) in the input string.
The constructor receives the input string from user. The other methods included:
summarize accumulates all the information about the input sentence, e.g. the
number of digits, uppercase letters, lowercase letters, and special characters. Hints:
the method relies on other methods to get the needed information.
countDigits returns the number of digits in a string. It returns 0 if none.
countUpper returns the number of upper-case letters in a string. It returns 0 if none.
countLower returns the number of lower-case in a string. It returns 0 if none.
countSpecialChars returns the number of special characters in a string. It returns
0 if none.
toString overrides the default method to return the formatted output
(see Figure 3).
getStr an accessor (getter) method, which returns value of the variable str.
setStr a mutator (setter) method used to control changes to variable str.
Guidelines:
Implement the class StringSummary.
There is no single solution to the implementation of each method. Be
creative and efficient.
After completing the implementations, test your program using the driver
class, StringSummaryDriver (Appendix A). Update your program until
satisfy. Submission requirements:
Copy the source code into Word file.
But also zip your source code for submission to OAS.
All codes to be accompanied with proper comments, where necessary.
Provide screen shots of your outputs (e.g. test using different sentences).
[65 marks]
b. The second part of the programming assignment extends from (a). Create a new
class called StringSummaryExtended. The class inherits the common
properties from StringSummary. It also included a new method known as
mergeStrings (Figure 4).
Figure 4: UML class diagram of
StringSummaryExtended class
A user will enter two strings of sentences in sequence, one after another (Figure 5). Then,
your program will use the mergeStrings method to merge/concatenate both sentences.
Finally, it displays a summary of the merged sentence as shown in sample output Figure
After entering the first sentence:
Figure 5: Sample input dialog box String Information
(i) Summary:
Read: this is aTest, 2020 is a year -2 is the first digit; the last is zer0!2nd input is this - Thank you
String length =100
Number of digits =7
Number of uppercase characters =2
Number of lowercase characters =63
Number of special characters =28
Figure 6: Sample output
Guidelines:
Implement the class StringSummaryExtended.
There is no single solution to the implementation of the method. Be creative
and efficient.
After completing the implementations, test your program using the driver
class, StringSummaryExtendedDriver (Appendix B). Update your
program until satisfy.
Submission requirements:
Copy the source code into Word file.
But also zip your source code for submission to OAS.
All codes to be accompanied with proper comments, where necessary.
Provide screen shots of your outputs (e.g. test using different sentences).
[15 marks]Listing 1: "Driver class for Question 2a"a. Explain at least TWO (2) major aspects of an object-oriented programming
(OOP). Provide suitable examples, where necessary.
b. Describe TWO (2) advantages of OOP.
[10 marks]
[10 marks]
Question 2(80 marks)
This programming assignment is divided into two parts:
a. You will develop a Java class called StringSummary based on the UML class
diagram depicted in Figure 1.
Figure 1: UML class diagram of StringSummary class
A user will enter a string of sentence as shown in Figure 2, and your program will provide
a summary of the sentence as shown in sample output Figure 3.
Figure 2: Sample input dialog box
 Figure 3: Sample output The class contains several private attributes: str

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!