Java Reference
In-Depth Information
Enter weight and price for package 1:
Enter weight and price for package 2:
Package 1 has a better price.
50 24.59
25 11.99
*3.34
( Geometry: point on line segment ) Exercise 3.32 shows how to test whether a
point is on an unbounded line. Revise Exercise 3.32 to test whether a point is on a
line segment. Write a program that prompts the user to enter the three points for
p0, p1, and p2 and displays whether p2 is on the line segment from p0 to p1. Here
are some sample runs:
Enter three points for p0, p1, and p2:
(1.5, 1.5) is on the line segment from (1.0, 1.0) to (2.5, 2.5)
1 1 2.5 2.5 1.5 1.5
Enter three points for p0, p1, and p2:
(3.5, 3.5) is not on the line segment from (1.0, 1.0) to (2.0, 2.0)
1 1 2 2 3.5 3.5
*3.35
( Decimal to hex ) Write a program that prompts the user to enter an integer
between 0 and 15 and displays its corresponding hex number. Here are some sam-
ple runs:
Enter a decimal value (0 to 15):
The hex value is B
11
Enter a decimal value (0 to 15):
The hex value is 5
5
31
Enter a decimal value (0 to 15):
Invalid input
 
Search WWH ::




Custom Search