lab4–CS101
October 30, 2007
1
Objectives
•
Method declaration and invocation
•
Math class
•
Loops and selection control
2
Lab description
In this lab assignment, you are going to implement a set of methods, each of
which is for solving a given task. The requirement of each methods is below.
In the main method, you shall write code to get user input and call each of
the following method. Please find some test cases for each method to test their
correctness.
2.1
method1
In business applications, you are often asked to compute the mean and standard
deviation of data.
Please write a method that generate ten random numbers
between 0 and 1000, including both 0 and 1000, and computes the mean and
standard deviations of these numbers using the following formula:
mean
=
∑
n
i
=1
x
i
n
=
x
1
+
x
2
+
...
+
x
n
n
(1)
deviation
=
radicaltp
radicalvertex
radicalvertex
radicalbt
∑
n
i
=1
x
2
i

(
∑
n
i
=1
x
i
)
2
n
n

1
(2)
The prototype of the method is
public static void meanDeviation()
2.2
method2
In this method, you should implement the sqrt method.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '07
 Vineyard
 Algorithms, Standard Deviation, Method, lastGuess

Click to edit the document details