( Latest Revision: Nov 06, 2011 )

Directions for Z-Lab

In this lab I want you to make a program that displays a rectangular pattern on the user's screen, like this:

--------------------
\\\\\\\\\\\\\\\\\\\\
++++++++++++++++++++
////////////////////
--------------------
\\\\\\\\\\\\\\\\\\\\
++++++++++++++++++++
////////////////////
I'll give you some extra credit on Solo #5 for your effort.

Start with a copy of the "var stars" program and transform it into a program that makes patterns like the one above for the user.

Here is a script illustrating what it should look like when you run your program:

john@lucifer: a.out

How wide do you want your pattern? 12

How many lines do you want in your pattern? 10

------------
\\\\\\\\\\\\
++++++++++++
////////////
------------
\\\\\\\\\\\\
++++++++++++
////////////
------------
\\\\\\\\\\\\

john@lucifer: 
You see in the program output part of the script above that the number of characters across is 12, the first number the user entered, and the number of lines in the pattern is 10, the second number the user entered.

The lines of the pattern cycle. Lines 1, 5, 9, and so on, when they exist, are made of dashes: -------. In the same way, lines 2, 6, 10, and so on, are backslashes: \\\\\\\, lines 3, 7, 11, and so on, are plus-signs: +++++++, and lines 4, 8, 12, and so on, are (forward) slashes: ///////.

The pattern contains backslashes, so remember that they have to be 'escaped'.

For this exercise, work with your lab partner.

If you like, you may also work with one of the other teams in your class. So that everyone will get proper credit, put the names of everyone who worked on the program in the comment at the beginning of the source code.

Stop working and e-mail whatever you have done, even if it is not complete, by the end of the 50-minute lab period on Wednesday, November 9. Use the following subject line.

CS1500_Z_Lab

Of course, you should test the program on appropriate inputs, but DO NOT send me a script this time.

As usual, you can refer to the Hello World! example for details on how to e-mail files to me.