Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program that draws a Sierpinski triangle, or asimilar object with any n

ID: 3610815 • Letter: C

Question

Create a program that draws a Sierpinski triangle, or asimilar object with any number of corners. Allow the user to inputthe number of corners and the number of iterations in textboxes.For extra credit, color the pixels based on how many times eachpixel has been drawn.
Suggested method
  1. Start by creating structure that defines points.
  2. Create an array to hold the corner points. Note that the sizeof the array will be determined by the user.
  3. Calculate the positions for the corner points, assign them tothe array, and display them on the screen. To start, make thecorners at least 4 pixels wide and 4 pixels high so you will besure to see them.
  4. Create a point variable that holds the current point. Randomlychoose one of the corner points to give you starting x and yvalues.
  5. Loop the number of times specified by the user, each timecalculating a new point position and drawing a 1 x 1 rectangle atthat point.
thanks Create a program that draws a Sierpinski triangle, or asimilar object with any number of corners. Allow the user to inputthe number of corners and the number of iterations in textboxes.For extra credit, color the pixels based on how many times eachpixel has been drawn.
Suggested method
  1. Start by creating structure that defines points.
  2. Create an array to hold the corner points. Note that the sizeof the array will be determined by the user.
  3. Calculate the positions for the corner points, assign them tothe array, and display them on the screen. To start, make thecorners at least 4 pixels wide and 4 pixels high so you will besure to see them.
  4. Create a point variable that holds the current point. Randomlychoose one of the corner points to give you starting x and yvalues.
  5. Loop the number of times specified by the user, each timecalculating a new point position and drawing a 1 x 1 rectangle atthat point.
thanks

Explanation / Answer

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace triangle
{
    public partial class Form1 : Form
    {
        public Form1()
        {
           InitializeComponent();
        }
    }
}

namespace triangle
{
    partial class Form1
    {
        /// <summary>
        /// Required designervariable.
        /// </summary>
        privateSystem.ComponentModel.IContainer components = null;

        ///<summary>
        /// Clean up anyresources being used.
        /// </summary>
        /// <paramname="disposing">true if managed resources should be disposed;otherwise, false.</param>
        protected override voidDispose(bool disposing)
        {
           if (disposing && (components != null))
           {
               components.Dispose();
           }
           base.Dispose(disposing);
        }

        #region Windows FormDesigner generated code

        ///<summary>
        /// Required method forDesigner support - do not modify
        /// the contents of thismethod with the code editor.
        /// </summary>
        private voidInitializeComponent()
        {
           this.components = new System.ComponentModel.Container();
           this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
           this.Text = "Form1";
        }

namespace triangle
{
    static class Program
    {
        /// <summary>
        /// The main entry pointfor the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
           Application.EnableVisualStyles();
           Application.SetCompatibleTextRenderingDefault(false);
           Application.Run(new Form1());
        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote