TW3 - Sliced to Order
- Worksheet 5 - Multiple Cases
- PQ1 - Flow Chart
- ZB4 - Looping
-
Teamwork 3 - Sliced to Order
Sliced to Order |
|
Instructions
Blue Teams; expected time to complete < 1 hour.
Create a custom string slicer.
- Required: A program that gets text and slicing parameters (start and end) from the user and prints out text in pieces using slices.
- Optional: The required program, but which also gets a stride parameter from the user and uses that to create the slice.
|
Quiz TW3: Step-by-Step is to be filled out individually by each team member during the team session.
|
|
TW3: Group Submission is to be handed in for the whole team by the team leader.
|
- the one from the beginning of the text to the beginning of their slice
- the requested slice
- the one from the end of their slice to the end of the text
Then print out the sliced-up string, indicating where the boundaries are by using the pipe character, |
, as a boundary marker.
Another requirement is that at least two of the slicing operations must use a default value for one of the positions (i.e., leave out the value before the colon or leave out the value after the colon in the slice operation).
For instance:
Enter some text, please:
That's impossible! How now, brown cow?
Slice starting position (zero for beginning): 4
Slice ending position (can be negative to count from end): 10
That|'s imp|ossible! How now, brown cow?
And
Enter some text, please:
That's totally possible!
Slice starting position (zero for beginning): 1
Slice ending position (can be negative to count from end): -2
T|hat's totally possibl|e!
Optionally, you can enhance your program to also ask for a stride value. If the user fails to specify a stride, you should default it to one.
Enter some text, please:
What's a stride, anyway?
Slice starting position (zero for beginning): 3
Slice ending position (can be negative to count from end): -4
Stride: 2
Wha|tsasrd,ay|way?