Answer & Explanation:In Java.
A.
Write a method where the signature is:
public static int subStrC(String s, char c)
Which receive a string ‘s’ and a char ‘c’ and returns how many sub string has in ‘s’ that ends in the char ‘c’ and they have inside them exactly one time the char ‘c’
for example. for the given string s=”abcbcabcacabcc” and the char c=’c’ the result would be 4
(because the sub strings are “cabcc”,”cacabc”,”cabcac”,”cbcabc”)
No need to return the sub strings. just the number of sub strings.
B.
Write a method where the signature is:
public static int subStrMaxC(String s, char c, int k)
That gets the string ‘s’, the char ‘c’ and a positive number ‘k’ and returns how many sub strings ‘s’ has that starts and ends in the char ‘c’ and Inside them maximum ‘k’ times the char ‘c’
No need to return the sub strings – just their numbers.
Examples:
1.If the string is: s=”abcbc” and char ‘c’=’c’ and the number k=0 the result is 1. (sub string is “CBC”)
2.If the string is: s=”abcbcabcacab” and char ‘c’=’c’ and number k=3 the result is 6 again (sub strings are “cbcabcac”, “cabcac”, “cbcabc”, “cac”, “cabc”, “cbc” and there is no sub string s that starts with char ‘c’ and ends in the char ‘c’ and has 3 ‘c’ chars).
3.If the strings is s=”abc”, char c=’c’ and number k=2 the result is 0. there is no sub strings that starts and ends in char ‘c’.
The methods needs to be as efficient as possible.
If the method complexity would be higher then required not all points will be given.
When solving those methods we can only use all the methods in the String class and in compare methods (optional) –
public char charAt(int i) – returns the char at the place i for the string it operated onpublic int length() – returns the length of the string.
You will get a plagiarism-free paper and you can get an originality report upon request.
All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more