Java Reference
In-Depth Information
Enter today's day:
Enter the number of days elapsed since today:
Today is Sunday and the future day is Wednesday
0
31
*3.6
(
Health application: BMI
) Revise Listing 3.5, ComputeAndInterpretBMI.java,
to let the user enter weight, feet, and inches. For example, if a person is 5 feet and
10 inches, you will enter
5
for feet and
10
for inches. Here is a sample run:
Enter weight in pounds:
Enter feet:
Enter inches:
BMI is 20.087702275404553
Normal
140
5
10
3.7
(
Financial application: monetary units
) Modify Listing 2.10, ComputeChange.java,
to display the nonzero denominations only, using singular words for single units such
as 1 dollar and 1 penny, and plural words for more than one unit such as 2 dollars and
3 pennies.
VideoNote
*3.8
(
Sort three integers
) Write a program that sorts three integers. The integers are
entered from the input dialogs and stored in variables
num1
,
num2
, and
num3
,
respectively. The program sorts the numbers so that
Sort three integers
num
1
…
num
2
…
num
3.
**3.9
(
Business: check ISBN-10
) An
ISBN-10
(International Standard Book Number)
consists of 10 digits: The last digit, is a checksum,
which is calculated from the other nine digits using the following formula:
d
1
d
2
d
3
d
4
d
5
d
6
d
7
d
8
d
9
d
10
.
d
10
,
(
d
1
*
+
d
2
*
+
d
3
*
+
d
4
*
+
d
5
*
+
1
2
3
4
5
d
6
*
6
+
d
7
*
7
+
d
8
*
8
+
d
9
*
9) % 11
If the checksum is
10
, the last digit is denoted as X according to the ISBN-10
convention. Write a program that prompts the user to enter the first 9 digits and
displays the 10-digit ISBN (including leading zeros). Your program should read
the input as an integer. Here are sample runs:
Enter the first 9 digits of an ISBN as integer:
The ISBN-10 number is 0136012671
013601267
Enter the first 9 digits of an ISBN as integer:
The ISBN-10 number is 013031997X
013031997
3.10
(
Game: addition quiz
) Listing 3.4, SubtractionQuiz.java, randomly generates a
subtraction question. Revise the program to randomly generate an addition ques-
tion with two integers less than 100.
Sections 3.9-3.19
*3.11
(
Find the number of days in a month
) Write a program that prompts the user to
enter the month and year and displays the number of days in the month. For