For this program you will hang three forces on a meter stick when you click a "Hang the Forces" button. When you click the "Solve" button, the magnitude and location of the equilibrant will be printed.
INPUTS:
The user will click the "Hang the Forces" button
A random standard force/box of 1-10 N will be printed to the screen
Three random forces (1-5 N) will be attached at 3 different locations on the meter stick.
OUTPUTS:
The user will click the "Solve" button
The equilibrant magnitude and location will be printed to the screen.
CRITERIA & CONSTRAINTS:
Your program should have an impressive interface. (colors and graphics)
A "Hang the Forces" and a "Solve" button will be displayed.
The equilibrant magnitude to the nearest whole number of Newtons and the location to the tenths place in centimeters will be printed to the screen.
On a spreadsheet make columns C-W to be a small width.
Insert a Google drawing and create a meter stick. Stretch it so that each decimeter lines up with a every other column from C-W.
We first need to clear any hanging boxes. Create a FOR loop from i = 0-10 incrementing i by 1.
In the FOR loop create a variable called column and set it equal to i*2+3.
Next, still within the FOR loop, create another FOR loop from row = 6-10 incrementing row by 1.
Within this FOR loop you will have two statements: 1.) set the background of each cell to whatever you are using as the color of your GUI. 2.) set the border of the cell to black. Use (row, column) as the cell reference in the getRange function.
Create three force magnitude variables f1, f2 and f3 and set them to a random number from 1-5.
Create three location variables loc1, loc2 and loc3 and set them to a random number from 0-10.
Use a while loop to reset loc2 if loc1==loc2.
Use another while loop to reset loc3 if loc3==loc1 or loc3==loc2
Time to hang the first force. Create a FOR loop from i=6 to i<f1+6 incrementing i by 1. In two statements, set the background color and the border of each force box. Use (i,loc1*2+3) as the cell reference in the getRange function.
Make two more FOR loops for f2/loc2 and f3/loc3 to hang the other two forces.
Create a standard_force variable and set it to random 1-10 N. Make a key by setting the background and border of some cell and printing the standard_force variable next to it.
Calculate the answer and print it to the screen, however, set the font color to match the background color so the answer does not show up.
Create a new function called get_answer( ). In this function simply change the font color of the answer to make it viewable.
Create two buttons: "Hang the Forces" and "Solve". The "Hang the Forces" button should call the balance( ) function and the "Solve" button should call the get_answer( ) function.