Lab 7v3
Lab 7v3
Rules:
You are not allowed to use any array or String
One only line where the word String may appear is in public static void main(String [] args) {
The word char must not be anywhere in your solution
Overall hint: Imagine all outputs as a matrix of space and star. Then count spaces and
stars to find out the trend of increment or decrement of number of stars/spaces. Utilize
several IF statement to control when star will be printed, when space will be printed
and when enter will be printed.
PROBLEM 3) Rectangle
Sample input:
4
6
Sample output
******
******
******
******
PROBLEM 4) Rectangle
Sample input:
4
6
Sample output
123456
123456
123456
123456
Page 1 of 7
PROBLEM 5) Triangle - Left Justified
Draw right angled triangle of given height
Sample input:
4
Sample output
*
**
***
****
Hint: One loop for lines, another loop for printing i number of starts when it is line i.
Page 2 of 7
PROBLEM 9) Triangle - Isosceles
Draw triangle of given height
Sample input 1:
3
Sample output 1:
*
***
*****
Sample input 2:
4
Sample output 2:
*
***
*****
*******
Sample input 2:
4
Sample output 2:
1
123
12345
1234567
Page 3 of 7
PROBLEM 12) Rhombus
Just draw the image of the above triangle once. And then, the opposite, once.
Sample input:
3
Sample output
*
***
*****
***
*
Page 4 of 7
PROBLEM 16) Hollow Triangle - Left Justified
Draw right angled triangle of given height
Sample input:
5
Sample output
*
**
* *
* *
*****
Page 5 of 7
PROBLEM 20) Hollow Triangle
Draw triangle of given height
Sample input 1:
3
Sample output 1:
*
* *
*****
Sample input 2:
4
Sample output 2:
*
* *
* *
*******
Sample input 2:
4
Sample output 2:
1
1 3
1 5
1234567
Page 6 of 7
PROBLEM 23) Hollow Rhombus
Just draw the image of the above triangle once. And then, the opposite, once.
Sample input:
3
Sample output
1
1 3
1 5
1 3
1
Page 7 of 7