Hey,
I'm having some trouble creating a method (in the form.....
)
that positions
string s in a field of a desired width. If the string is longer than the desired field width, it will need to be truncated. If it is shorter than the desired field width it will need to be padded with blank characters. The alignment parameter determines whether the string will be left aligned ('L' or 'l') in the field (padding added to the right) or right aligned ('R' or 'r') in the field (padding added to the left). And if there are not enough spaces to display the string, at least one space must be provided on the appropriate side.
I've been playing around with it:
And I've been
testing it in various ways. But ultimately the I/O should look similar to this:
I've been struggling with this for quite some time now,
so any help would be greatly appreciated.
Thanks,
n