Starting from:

$30

CSE 110 - Lab 5

CSE 110 - Lab 5
Lab Topics
● More loops & Nested loops
● Getting familiar with static methods
Lab Problem: Designing Patterns by Loops
Please design a program that can produce different patterns according to the user input. You have to
implement at least two patterns from the following list (please check the sample output for the shapes
of these patterns):
● A row of symbols
● A pyramid
● An inverted diamond (challenge)
Moreover, instead of placing everything inside the main function, you have to design several static
helper methods beside the main function. You need to define at least the following methods:
● buildRow(char sideSymb, int sideWidth, char midSymb, int midWidth)
● buildPyramid(char sideSymb, char midSymb, int ptnHeight)
You may download the template here Lab5 .java to help you to start the lab. You can add and declare
any other variables & methods you need or you prefer you write lab5 from scratch.
Note: If you are using the template, you may go to “buildRow” and “buildPyramid” directly and put
in your code.
Sample Output
Below is an example of what your output should roughly look like when this lab is completed. Text in
RED represents user input.
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
r
Width of the sides?
2
Width of the middle?
4
--****--
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
r
Width of the sides?
4
Width of the middle?
2
----**----
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
p
Number of symbols on the lowest layer?
5
--*--
-***-
*****
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
p
Number of symbols on the lowest layer?
7
---*---
--***--
-*****-
*******
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
p
Number of symbols on the lowest layer?
10
The input is not an odd number. Use the closest odd number below 10
----*----
---***---
--*****--
-*******-
*********
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
d
Number of symbols on the middle layer?
11
***** *****
**** ****
*** ***
** **
* *

* *
** **
*** ***
**** ****
***** *****
Please choose one pattern from the list:
r) Row
p) Pyramid
d) Shallow diamond
q) Quit
q
Bye
Make sure to upload your Lab5.java
Please submit your Lab5.java ONLY to “Lab 5 Upload Link” in Weekly Labs section. Do not include
any Eclipse project files. 

More products