Prog 1: Gladiolus

Write a program and test it within the Zylab section 3.28 programming environment that allows you to print an ASCII version of a Gladiolus flower. Larger numbers give larger flowers. The number of input sections should be 1 or higher, where all sections are centered above each other as shown.

Running the program and choosing option 2 must look exactly like the sample shown in the Google Doc below so that it matches the expected output in the Zybooks automated testing environment.

Prog 1 Gladiolus in ASCII

What You Need to Know

  • Environment: How to write a program within the Zylab environment, and how to run the assessments within that environment

  • C++ Language concepts needed are included in the sample code in file sample.cpp . The concepts you need are: simple input ( cin) and output (cout), setting an output field width using setw(), using int variables, incrementing a variable, the assignment statement (=), how to compare variable values, repeating a group of statements using a for or a while loop, choosing between alternatives using an if-else statement.

  • You need to know that the backslash '\' character has special meaning in an output statement. In order to cause the backslash character itself to show up in your output, you must put two backslashes in a row inside double quotes, such as: cout << " \\" << endl;

Implementation

  • Start with the code in sample.cpp (also supplied by default within the Zylab) and paste it into your programming environment. This will help ensure your menu is spaced exactly like the one in the expected output.

  • Think of some UIC or Chicago oriented image (or something else) and make your own original implementation of it using ASCII graphics, having your program display it when menu option 1 is selected. (Want inspiration? Do a google search on "ASCII graphics".) This should be in good taste (e.g. not obscene, or violent, etc., and may be selected to join the public gallery of student-made work for this assignment. It should not be substantially similar to the code used in part 2 of this program, it must be between 5 and 80 lines of output, with a maximum width of 100 characters per line.

  • Read the parts of our online Zybook that you need to use in this program.

  • Make your output exactly like the sample output so that you match the expected output in the built-in Zybook tests.

Points

  1. To get up to 45 execution points for your program you must run the assessments within the Zylab before the deadline. The last couple of tests have hidden input and output and will only tell you if your output was correct.

  2. You will get 10 additional execution points (giving a total of 55) for having your original ASCII graphic. You will receive full credit for your ASCII graphic if it is original and interesting and satisfies the requirements described above for number of lines, max line size, and use of a loop.

  3. To get the 45 style points for your program you must separately turn in a copy of your main.cpp source code file into the Gradescope Prog1: Gladiolus assignment before the deadline. Include a copy of your original ASCII graphic in the header documentation of your program, otherwise you will lose 5 points. For this first program we do not expect you to use functions (though you may if you want to).

Suggested Steps

The steps described below will help you make progress. You may want to see if you can first do it on your own without these steps. Then if you get stuck you can come back and take a look.

  1. After prompting for how many sections, use a loop to display a single left parenthesis on a single line for each section, with a line of three dashes after each one. Thus if the user chooses 3 sections the output might look like:

2. Add a loop inside your existing loop so each section has the appropriate number of lines, though each line is still just a left parenthesis. This should work for any input number, giving the right number of sections, and the right number of lines per section.

3. Add a loop or a setw() output width specifier to display the appropriate number of blanks before each parenthesis. To do this you will need to figure out a formula. On each line you know how many sections there are and which line you are on. Using these two numbers figure out some formula that gives the appropriate width of blank spaces to be displayed before each '('. Your output should now look like:

3. Separate out the middle line containing the '@' from the other lines for each section, handling it separately. Figure out for that middle line in each of the sections how many blanks should be displayed before the '@'. Maybe also add the code to give the correct number of leading spaces before the "---" lines as well. This should now look like:

4. Similarly continue with figuring out the number of blank spaces to be displayed before the ')' is displayed at the end of each line. At this point you've probably got the hang of it, breaking down the problem into smaller steps where each one may be challenging, but possible to do. Don't forget to check the programs grading criteria in the syllabus, and don't forget to submit the final version to Gradescope so we can give you program style points.