Question: Use java language This program is a program for converting the format of a string from one form to another, according to the following criteria:

Use java language
This program is a program for converting the format of a string from one form to another, according to the following criteria:
The program will read the text from the input string, assuming a name S with a size of n characters, where 1<=n<=4096(meaning S must consist of at least 1 character and not exceed 4096 characters).
Student "" should write a program to change input string S to output string O. When entering the input string S,"" must always enter the character '$' at the end of the string.
When the program changes the value of string S to string O, the program will not print the character '$' in the output string O.
Student "" should write a program to count the number of consecutive and duplicate English alphabet characters in the input string S and print the value of (1) the number of individual English alphabet characters (2) the number of consecutive and duplicate characters (referred to as variable k) in the output string O.
a. In cases where the alphabet characters have only one occurrence and are not repeated consecutively, the program will set the value of k=1.
b. Uppercase and lowercase English alphabet characters (e.g.,'A' and 'a') are considered different characters.
Example:
If student "" inputs a string of 12 characters followed by $:
aaaBBcdefFF$
The program will produce the output string as:
a4B2c1d1e1f1F2
Because the input string has 4 consecutive 'a' characters (k=4),2 consecutive 'B' characters (k=2),'c','d','e', and 'f' characters are not repeated consecutively (k=1), and 'F' has 2 consecutive characters (k=2).
Input:
The input consists of 1 line:
Line 1 contains a string of n characters (1<=n<=4096) followed by '$'.
Note: In this program, we assume that the input data is always correct, so students do not need to verify the correctness of the input data. This means:
(1) No need to check if 1<=n<=4096.
Line 1 contain a String
input :
s$
output :
s1
input :
aaaaaaaaaaaaaaaaBBBBBBccEFG$
output :
a16B6c2E1F1G1
input :
kkkkkkpppppQQQQkkkppQ$
output :
k6p5Q4k3p2Q1s

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!