ICS3U7Assignment: Shape Generator
In the old days when pixel graphics are not widely supported by the monitors, text graphics were commonly used. Nowadays, it seems the pixel graphics is coming back in trend. Text graphics are pictures or images that are formed by text characters. Visit the following site to see some samples:
Heart text arts (using text symbols) - fsymbols
You will write a program that draws, only using *, a total of six different forms of 4 different shapes: lines, rectangle, triangle and trapezoid
*********
Horizontal line (length of 9)
*
*
*
*
Vertical line (length of 4)
*****
*****
*****
Rectangle (width of 5, length of 3)
*
**
***
****
*****
Left slant right angle triangle (height of 5)
*******
*****
***
*
Isosceles triangle (upside down; height of 4)
****
******
********
trapezoid (top base 4,height of 3)
The user will specify the shape as well as the dimension of the shape.
Your program should perform the following steps in order:
1. Ask user for the choice of the shape (specified by numbers)
i) Horizontal line
ii) Vertical line
iii) Rectangle
iv) Left slant right angle triangle
v) Isosceles triangle (upside down)
vi) Trapezoid
2. Ask user for the dimension of the shape (length for lines, length and width for rectangle, height of triangles, top base and height), maximum dimension is 20
3. Draw the shape with specified properties
4. Ask user if they want to continue
• If user answers ‘y’ or ‘Y’ (for yes), repeat step 1 to 4
• If user answers ‘n’ or ‘N’ (for no), the program will output the numbers of each shape that are drawn, then terminate the program
Your program should validate all users’ input. If they are not valid, the program should continue prompting for input until they are correct.
Here is a sample output of the program:
Welcome to the Shape Generator:
This program draws the following shapes:
1) Horizontal Line
2) Vertical Line
3) Rectangle
4) Left slant right angle triangle
5) Isosceles triangle
6) Trapezoid
Enter your choice (1-5): 7
Invalid choice! Your choice must be between 1 and 6.
Enter your choice (1-5): 3
Enter the width of the rectangle (1-20): 3
Enter the length of the rectangle (1-20): 2
Here is the rectangle:
***
***
Would you like to draw another one (y/n)? Y
This program draws the following shapes:
1) Horizontal Line
2) Vertical Line
3) Rectangle
4) Left slant right angle triangle
5) Isosceles triangle
6) Trapezoid
Enter your choice (1-5): 1
Enter the length of the horizontal line (1-20): -1
Invalid dimension! The dimension must be between 1 and 20.
Enter the height of the horizontal line (1-20): 25
Invalid dimension! The dimension must be between 1 and 20.
Enter the length of the horizontal line (1-20): 6
Here is the horizontal line:
******
Would you like to draw another one (y/n)? z
Invalid input! Your input must be ‘y’ or ‘n’.
Would you like to draw another one (y/n)? n
Here is a summary of the shapes that are drawn.
Horizontal Line 1
Vertical Line 0
Rectangle 1
Right slant right angle triangle 0
Isosceles triangle 0
Trapezoid 0
Thank you for using Shape Generator. Good Bye!!
Save your program as Shape.java. Please mark sure to have the exactly same input and output format as shown above for full marks.
Due Date: Friday, March 23, 2012
Assessment:
Application
Correctness of Input (users’ input is validated): 10
Correctness of Output (shapes are outputted correctly): 12
Thinking / Inquiry
Program Design (efficiency, choice of structure): 10
Communication
Documentation (program header, explanation of code): 5
Submission (correct file names, on time) 5
I know i need loops, i did while, do while, and for. Plz use these to help. Whoever helps, wille recieve $20 via Paypal. If u answer post ur email/ paypal ID and i will send u the money if satisfied, and the output is exactly the same