Program that draws a square on the screen


Question 1: You have eight bars of gold, one of which is counterfeit and is heavier than the rest. You also have a balance: you load both pans of the balance, and whichever side is heavier sinks. If both pans contain the same weight, the balance stays level. Describe a process for discovering which bar is counterfeit.

Question 2: Using processing, you want to make an ellipse travel around the perimeter of the window, going clockwise starting from the top left corner. That is, it will go across the top until it reaches the edge, then down the right side, then travel left across the bottom, up the left edge to the top, and then begin again. Describe a plan for this program. (Don't actually write the program, just give a plan, including listing variables and giving details of the actions you would take during the setup and draw phases.)

Question 3: You want to plot a graph of the function y=x^2 (x squared). Describe a plan for doing it in processing. (Don't write a program, just describe how you would go about it, including listing variables and saying what actions you would take during setup and during the draw loop.)

Question 4: Write a program that draws a square on the screen. The square should appear at a new random location every time you run the program.

Question 5: Write a "countdown": starting with 9, the numbers 8, 7, 6, and so on should appear, until 0 is reached, at which point the numbers should disappear.

Question 6: Modify the "simplepaint" program from last time so that it can draw in different colors. Write your initials (at least three characters) using three different colors, one color per letter. Submit the code and your drawing.

Question 7: Draw an ellipse in the middle of the screen. The ellipse should be one color when the mouse is touching it and another color when the mouse pointer is off it. (It will be easier if the ellipse is a circle -- do the full calculation for an arbitary ellipse only if you want the challenge.)

Question 8: Display the x position of the mouse as a percentage of the window width. For example, if the pointer is three-quarters of the way across the window, you should display "75".

Question 9: An old style of grading has four possible grades: "first class" (80% and above), "second class" (65 to 80), "pass" (50 to 65), and "fail" (below 50). Modify your program from #8 to display the appropriate grade from among these four possibilities instead of displaying the percentage.

Question 10: Draw three bubbles (use ellipses). The bubbles should rise towards the top of the screen as time passes. When a bubble reaches the top, it should vanish and a new bubble should appear at a random location and then start rising.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Program that draws a square on the screen
Reference No:- TGS01237

Expected delivery within 24 Hours