expand icon
book Programming Logic and Design, Introductory 7th Edition by Joyce Farrell cover

Programming Logic and Design, Introductory 7th Edition by Joyce Farrell

Edition 7ISBN: 1285225562
book Programming Logic and Design, Introductory 7th Edition by Joyce Farrell cover

Programming Logic and Design, Introductory 7th Edition by Joyce Farrell

Edition 7ISBN: 1285225562
Exercise 7

Assume that you have created a mechanical arm that can hold a pen. The arm can perform the following tasks:

• Lower the pen to a piece of paper.

• Raise the pen from the paper.

• Move the pen 1 inch along a straight line. (If the pen is lowered, this action draws a 1-inch line from left to right; if the pen is raised, this action just repositions the pen 1 inch to the right.)

• Turn 90 degrees to the right.

• Draw a circle that is 1 inch in diameter.

Draw a structured flowchart or write structured pseudocode describing the logic that would cause the arm to draw or write the following. Have a fellow student act as the mechanical arm and carry out your instructions. Don’t reveal the desired outcome to your partner until the exercise is complete.

a. a 1-inch square

b. a 2-inch by 1-inch rectangle

c. a string of three beads

d. a short word (for example, cat)

e. a four-digit number

Step-by-step solution
Verified
like image
like image

Step 1 of 3

b) A two-inch by one-inch rectangle

Pseudocode:

start

Lower the pen to a piece of paper

Move 1 inch along a straight line

Move 1 inch along a straight line

Turn 90 degrees to the right

Move 1 inch along a straight line

Turn 90 degrees to the right

Move 1 inch along a straight line

Move 1 inch along a straight line

Turn 90 degrees to the right

Move 1 inch along a straight line

Raise the pen from the paper

stop

Flowchart:

    <div class=answer> b) A two-inch by one-inch rectangle Pseudocode : start Lower the pen to a piece of paper Move 1 inch along a straight line Move 1 inch along a straight line Turn 90 degrees to the right Move 1 inch along a straight line Turn 90 degrees to the right Move 1 inch along a straight line Move 1 inch along a straight line Turn 90 degrees to the right Move 1 inch along a straight line Raise the pen from the paper stop Flowchart:


Step 2 of 3


Step 3 of 3

close menu
Programming Logic and Design, Introductory 7th Edition by Joyce Farrell
cross icon