In this lab you will write an applet that operates on an array of integers and performs 4 statistical operations on it: minimum, maximum, average (Arithmetic mean) and Standard deviation. You will have to write the code of Standard Deviation from scratch (rather, use the one you have already written from scratch as the prelab.)
Your applet should also display the numbers in the array, one at a time.
Start/Launch Eclipse and snarf a new the labs/07_Arrays project
You will need to add awb.jar to your build path by going to project Properties, then select Java Build Path, click Libraries, and then select Add JARs and find the awb.jar in your project.
To the existing ArrayStats program you need to add one button "Standard Deviation" which on clicking displays the standard deviation of the array of numbers. Also instead of using a double array you will use an integer array.
For each of the buttons Show, Extremes, Mean, Standard Deviation you may assume that they are clicked only after at-least one value is stored in the array
In the ArrayStatsExtendedclass that you snarfed, add the Standard Deviation method from your Prelab. For rest of the methods you need to modify the ones in ArrayStats.java to use an int array instead of double so that you return an int value and accept int array as parameter instead of double. (The methods which return the mean and the one you wrote for Standard Deviation will be the exceptions, they will return a double each.)
Add code to create and add to the screen a button called "Standard Deviation". Make sure you add an ActionListener to all your Buttons.
Add code to define operation of the Standard Deviation button. When the user clicks the button, your program should call your standardDeviation method and display the output in a the output TextField.
After you complete your code, taking some from the ArrayStats.java applet and that for the Standard Deviation operation. You need to Build and Run your project/ lab7. To do this, Right-click on the lab7 project and choose “Run as” -> “Java Applet” .
The ArrayStatsExtended.html file will display the applet.You need to edit it. (DO NOT Double-Click or try to open it with the Eclipse Web Browser. This is the Default option (unfortunately) and will cause Eclipse to FREEZE!) Edit this file (Right-Click -> Open with-> Text Editor) to include your name, netId and other information ( Collaborators, Resources used..).
Make sure to test several possible input values when you run your applet via Eclipse. If your applet gives incorrect results for trivial sets of numbers, then there is a problem in your subroutine. Go back and check your computation for logic errors, fix them, and recompile. (For computational errors, check if the while loops are running for the exact number of times as you want them to and then check if any operations need parentheses around them.
Your applet exists only in Eclipse work-space as of now. Besides submitting your ArrayStatsExtended.java file and ArrayStatsExtended.html file via Eclipse as shown below, you also need to “export your project” to your public_html/cps1 folder to ensure it works over the Internet.
To Export your 07_Arrays project, Right-click on the 07_Arrays project and choose “Export”
In the next window, Choose “File System” and click “Next”.
The next window will ask you to choose a Destination Folder. Hit the “Browse” button and navigate to “P:\public_html\cps1\” folder and hit “Finish”.
This will create a new folder in the destination folder with the same name as the Eclipse project. (i.e. Eclipse will create a 07_Arrays folder in P:\public_html\cps1 folder which will have both the ArrayStatsExtended.java and the HTML file necessary to run the applet.
If you did everything correctly, you should be able to go to the URL
and view your applet (replace login with your acpub login).
In Lab 1 we made a webpage for this class named index.html . Add a link to your applet on your CPS1 page. The easiest thing to do is to ADD this to the un-ordered list already present on your webpage. For example, you could do something like this:
<ul> <li> <a href = "http://www.duke.edu/~login/cps1/07_Arrays/ArrayStatsExtended.html"> Lab 7: Working with Arrays</a> </ul>
Submit your ArrayStatsExtended.java and ArrayStatsExtended.html files using Eclipse. See the Ambient submit instructions. You should submit under class cps001, assignment name lab7.
Also, make sure that your applet also works over the Internet at the above mentioned link.