Java Reference
In-Depth Information
you how tightly all the various data are clustered around the mean in a set of data.
For example, what is the average age of the students in a class? How close are the
ages? If all the students are the same age, the deviation is 0.
Write a program that prompts the user to enter ten numbers, and displays the
mean and standard deviations of these numbers using the following formula:
n
2
¢
x
i
≤
a
n
n
i
=
1
x
i
x
i
-
a
a
n
x
1
+
x
2
+
g
+
x
n
i
=
1
i
=
1
mean
=
=
deviation
=
c
n
n
n
-
1
Here is a sample run:
Enter ten numbers: 1 2 3 4.5 5.6 6 7 8 9 10
The mean is 5.61
The standard deviation is 2.99794
*5.46
(
Reverse a string
) Write a program that prompts the user to enter a string and
displays the string in reverse order.
Enter a string: ABCD
The reversed string is DCBA
*5.47
(
Business: check ISBN-13
)
ISBN-13
is a new standard for indentifying topics. It
uses 13 digits
d
1
d
2
d
3
d
4
d
5
d
6
d
7
d
8
d
9
d
10
d
11
d
12
d
13
. The last digit
d
13
is a checksum,
which is calculated from the other digits using the following formula:
10
-
(
d
1
+
3
d
2
+
d
3
+
3
d
4
+
d
5
+
3
d
6
+
d
7
+
3
d
8
+
d
9
+
3
d
10
+
d
11
+
3
d
12
)%10
If the checksum is
10
, replace it with
0
. Your program should read the input as a
string. Here are sample runs:
Enter the first 12 digits of an ISBN-13 as a string: 978013213080
The ISBN-13 number is 9780132130806
Enter the first 12 digits of an ISBN-13 as a string: 978013213079
The ISBN-13 number is 9780132130790
Enter the first 12 digits of an ISBN-13 as a string: 97801320
97801320 is an invalid input
*5.48
(
Process string
) Write a program that prompts the user to enter a string and dis-
plays the characters at odd positions. Here is a sample run:
Enter a string: Beijing Chicago
BiigCiao
Search WWH ::
Custom Search