stitching

Category: Programming
Author: Helene Martin and Marty Stepp
Book Chapter: 4.2
Problem: stitching
Write a static method named stitching that accepts two integer parameters w and h and that prints a rectangle of dashes and numbers. Each of the h lines printed will contain w integers separated by dashes. The first number on each line is the line number. For example, the first line's first number is 1 and the sixth line's first number is 6. The lines alternate between starting with a dash and ending with a dash. For example, the first, third and fifth lines start with a dash and the second, fourth and sixth lines start with a number. You may assume that the value of each parameter is greater than or equal to 1. Your output must exactly match the format shown.

stitching(6, 2);
-1-2-3-4-5-6
2-3-4-5-6-7-

stitching(2, 3);
-1-2
2-3-
-3-4

stitching(2, 6);
-1-2
2-3-
-3-4
4-5-
-5-6
6-7-

stitching(1, 1);
-1