Access over 35 million academic & study documents

5 strPtr(s1) This function will take a string which has two single

Content type
User Generated
Rating
Showing Page:
1/11
5. strPtr(s1) This function will take a string which has two
single-digit integers somewhere in it. The first integer
found is the starting point. The second integer is the
substring length. The output from this function is a return
of a substring of the string parameter with numbers
removed first, which begins at the starting point and
returns a string the length indicated by the substring length
integer. Output must be presented in the format identical to
that in the check function at the bottom of the template. If
an empty string is passed in, the following string will be
returned in identical format to the one shown: \"Empty
string\" If the integers passed in as starting and length
values are invalid when applied to the string (after the
numbers have been removed from it), the following string
will be returned in identical format to the one shown:
Invalid indices\" Output MUST BE as presented in the
EXACT format used in the call to the check function at the
bottom of the template. SAMPLE RUNS strPtr(\'\') will
return this string in the following format: \"Empty string\"
strPtr(\'a39abcdefghiljklmnopa\') will return this string in
the following format: \'cdefghilj\' strPtr(\'a27\') will return
this string in the following format: \"Invalid indices def
strPtr(s1): pass # Use this return statement to return the
string s2 where s2 is your substring #return s2 # Use this
return statement for an empty string #return (\"Empty
string\") # # # # This function takes a two dimensional list:
a value, an address. The object is to start at the first entry
in the list # and use the address to go to the next entry in
the list to get the next address. If you can end up at 0 by
the end then # you have completed the game. If you
cannot get to 0 (just keep moving through the list) then
there is an error. If the # address points to an invalid entry
then there is an error. Keep count of the number of jumps.
Going into the first entry # is the first jump. # # INPUT: two
dimensional list with the first entry being a value and the

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/11
second being an address # # OUTPUT: if successful then
count of number of jumps (going to the first entry counts as
1) and the sting \"Made it home in\", count # # ERROR
CHECK: \"No valid path.\" and \"No valid path. Duplicate
visits.\"
Solution
i hope u will understand this program
public class Recursion {
/** Return the number of times c occurs in s. */
public static int number(char c, String s) {
if (s.length() == 0) return 0;
return (c == s.charAt(0) ? 1 : 0) + number(c,
s.substring(1));
}
/** Return a copy of s with each character duplicated. */
public static String dup(String s) {
if (s.length() == 0) return s;
return s.charAt(0) + (s.charAt(0) +
dup(s.substring(1)));
}
/** Return a copy of s with duplicate adjacent chars
deleted.

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/11

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 11 pages?
Access Now
Unformatted Attachment Preview
5. strPtr(s1) This function will take a string which has two single-digit integers somewhere in it. The first integer found is the starting point. The second integer is the substring length. The output from this function is a return of a substring of the string parameter with numbers removed first, which begins at the starting point and returns a string the length indicated by the substring length integer. Output must be presented in the format identical to that in the check function at the bottom of the template. If an empty string is passed in, the following string will be returned in identical format to the one shown: \"Empty string\" If the integers passed in as starting and length values are invalid when applied to the string (after th e numbers have been removed from it), the following string will be returned in identical format to the one shown: “Invalid indices\" Output MUST BE as presented in the EXACT format used in the call to the check function at the bottom of the template. SAMPL E RUNS strPtr(\'\') will return this string in the following format: \"Empty string\" strPtr(\'a39abcdefghiljklmnopa\') will return this string in the following format: \'cdefghilj\' strPtr(\'a27\') will return this string in the following format: \"Invalid indices” def strPtr(s1): pass # Use this return statement to return the string s2 where s2 is your substring #return s2 # Use this return statement for an empty string #return ( \"Empty string\") # # # # This function takes a two ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
This is great! Exactly what I wanted.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4