21. Stars

Write a program that lets the user enter a number of sides and a skip number. It should then draw a regular polygon with the indicated number of sides. It should also draw a star by connecting each of the polygon's vertices to the vertex that is the skip number of steps away around the perimeter of the polygon.

For example, the following screenshot shows the Stars example solution drawing a pentagon and a five-pointed star. The skip number is two, so the program draws the star by connecting each vertex with the point that is two positions away from it around the edge of the polygon:

If you experiment with the program, you'll find that some skip numbers produce disconnected stars. In other words, the points on the star are not all joined by a continuous sequence of connected line segments. For example, try a 12-sided polygon with the skip number 8. What is the relationship between the skip number and the number of polygon sides for these disconnected stars?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.237.115