Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a single function that draws on the console a regular polygon with n sides where n is passed in when the function is called

Write a single function that draws on the console a regular polygon with n sides where n is passed in when the function is called from main(). I have provided a template C++ program for you to start with. I have also provided an image with regular polygons with 3 to 10 sides, however your function should only draw one polygon with the number of sides passed into it when called.

image text in transcribed

- Make sure the bottom most side of the polygon is horizontal with your computer screen.

- Every polygon must have a constant radius of 100

- You are not allowed to use any other libraries other than what I have provided.

- Code must be your own that you developed yourself. It would be wise to show me any scratch paper work that was necessary for you to reach your solution.

- You are permitted to use any built in functions provided in the cmath library.

- Comment your code and make sure you are able to describe how it works.

- Submit the final .cpp file here.

2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 #include #include // Depending on you solution, you may or may not need these defines #define PI 3.141592 #define OFFSET 200 using namespace std; // Prototype for the function you will define void drawPolygon (HDC&, COLORREF&, int); Gint main() { HWIND myConsole = GetConsoleWindow(); HDC mdc = GetDC (myConsole); COLORREF COLOR = RGB(0, 255, 0); // Draw a regular triangle drawPolygon(mdc, COLOR, 3); // Draw a regular square drawPolygon (mdc, COLOR, 4); 1/ Draw a regular pentagon drawPolygon(mdc, COLOR, 5); // Etc...... ReleaseDC(myConsole, mdc); cin.ignore(); return; // The function you must define. The parameter sides is how many sides the (1/ regular polygon should have. void drawpolygon(HDC& mdc, COLORREF& COLOR, int sides) { // Write your code in here // Don't forget to print a pixel, use SetPixel(mdc, x, y, COLOR); 1 estreatistarreplanellaiayyapan . A

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Has the priority order been provided by someone else?

Answered: 1 week ago

Question

Compare the current team to the ideal team.

Answered: 1 week ago