This is for a lab. Help on any or all of the following would be greatly apprecia
ID: 3875546 • Letter: T
Question
This is for a lab. Help on any or all of the following would be greatly appreciated!
1. Write an un-named algorithm for drawing a square that is 2 inches on each side.
2. Write an un-named algorithm for drawing a generic right triangle (i.e., a right triangle whose size is not determined in advance). The person executing the algorithm should be instructed to ask for the base and height of the right triangle.
3. Write an un-named algorithm for calculating and displaying the perimeter of a generic rectangle (i.e., a rectangle whose size is not determined in advance). The person executing the algorithm should be instructed to ask for the width and height of the rectangle
4. Write an un-named algorithm for calculating and displaying the total combined area of three shapes: a square, an equilateral triangle, and a circle. The person executing the algorithm should be instructed to ask for a single number that will be used for the length of the sides of the square, the length of the sides of the triangle, and the radius of the circle. (Note: You may look up any equations you have forgotten.)
Explanation / Answer
1.Algorithm for drawing a square of side 2 inches
1.Draw a horizontal line of length 2 inches.
2.Draw two prependicular lines of length 2 inches at both the ends of the line.
3. Join the top points of the prependicular lines.
4. Square is ready.
2. Algorithm for drwaing a right anagled traiangle.
1. Take input for the length of the base and height of the traiangle.
2. Draw a horizontal line(base) of length as specified in step 1 for base
3. At one of the end of the line draw a perpendicular line of length as specified in step 1 for height
4. Join the other end of the line with the top point of the perpendicular line
5. Righ angled triangle is ready.
3. Algorithm for calculating and displaying the permeter of the reactangle:
1. Take the input for width and height of the rectangle
2. Calculate the perimeter as 2 * (width + height)
3. Display the result obtained in step 2.
4.3. Algorithm for calculating and displaying the combined area of a square, an equilateral triangle and a circle:
1. Take the input for the side
2. Calculate the area of square as A = side * side
3. Calculate the area of equilateral traangle as as E = 1/2 *(side) * (sqrt(side * side - side/2 *side/2))
4. Calculate area of Circle as C= pi * side * side
5. Calculate the combined Area CA = A + E + C.
6. Display the result as obtained in step 5.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.