1. GUI with button control: Write a C# program with at least 2 buttons and at least two other kinds of GUIs. Use these buttons to control the size, color (foreground color, background color), font, etc. of at least 5 Properties of the Button or any other BUIs.

2. Draw the image of YinYang using C# 2D graphics methods.

Figure 1. Image of Yin Yang. see image.

Magic Square

A magic square of dimension n is a square of n2 integers from 1, 2, until n2 so that the row sum of all n rows and the column sums of all n columns are all equal (to n (n2 + 1)/2). For example, when n = 3, there are 9 squares with the 3 row sums and 3 column sums equal to 3 * (9 + 1) / 2 or 15. When n = 5, the row sums and column sums are equal to 65.

Figure 2. Image of 3x3 magic Square with numbers and grid shown. see image.

3. Write a C# program that prompts you to enter the size of magic square and output a magic square of that size. The following shows the outputs for n = 3 and n = 5 using a special algorithm. Run your program for n = 3, n = 5 and n = 7.

Note these magic squares of odd sizes (n = 3, 5, 7, 9 etc.) are generated this way: First put 1 in the middle of the 0th row. Then move to the upper right. If the number is out of the square, then wrap around to the last or n-1st row or wrap around to the 0th or the leftmost column. So for n = 5, 1 is in position (0, 2), i.e. row 0 and column 2, and 2 is in (4, 3), 3 is in (3, 4) and 4 after wrap around is in (2, 0). At the multiple of n numbers like 5, 10, 15 etc. for n = 5, the next number is right below that (hence 6 is below 5, 11 is below 10 etc.).

Input magic square size
5
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9

Input magic square size
3
8 1 6
3 5 7
4 9 2

4. Add 2D graphics to magic square so that the numbers and grid are shown like in Figure 2. Do the graphics for n = 3, 5, and 7.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.