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 nmeaning S must consist of at least character and not exceed 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 the number of individual English alphabet characters 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
b Uppercase and lowercase English alphabet characters egA and a are considered different characters.
Example:
If student inputs a string of characters followed by $:
aaaBBcdefFF$
The program will produce the output string as:
aBcdefF
Because the input string has consecutive a characters k consecutive B characters kcde and f characters are not repeated consecutively k and F has consecutive characters k
Input:
The input consists of line:
Line contains a string of n characters n 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:
No need to check if n
Line contain a String
input :
s$
output :
s
input :
aaaaaaaaaaaaaaaaBBBBBBccEFG$
output :
aBcEFG
input :
kkkkkkpppppQQQQkkkppQ$
output :
kpQkpQs
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
