Java Reference
In-Depth Information
Enter weight in pounds:
Enter height in inches:
BMI is 26.8573
95.5
50
*2.15
( Geometry: area of a triangle ) Write a program that prompts the user to enter
three points (x1, y1) , (x2, y2) , (x3, y3) of a triangle and displays its area.
The formula for computing the area of a triangle is
=
+
+
s
( side 1
side 2
side 3)/2;
area
= 2
s ( s
-
side 1)( s
-
side 2)( s
-
side 3)
Here is a sample run:
Enter three points for a triangle:
The area of the triangle is 33.6
1.5 -3.4 4.6 5 9.5 -3.4
2.16
( Geometry: area of a hexagon ) Write a program that prompts the user to enter the side
of a hexagon and displays its area. The formula for computing the area of a hexagon is
3
2
3
s 2 ,
Area
=
2
where s is the length of a side. Here is a sample run:
5.5
Enter the side:
The area of the hexagon is 78.5895
*2.17
( Science: wind-chill temperature ) How cold is it outside? The temperature alone is
not enough to provide the answer. Other factors including wind speed, relative
humidity, and sunshine play important roles in determining coldness outside. In
2001, the National Weather Service (NWS) implemented the new wind-chill tem-
perature to measure the coldness using temperature and wind speed. The formula is:
35.75 v 0.16
0.4275 t a v 0.16
t wc =
35.74
+
0.6215 t a -
+
where is the outside temperature measured in degrees Fahrenheit and v is the speed
measured in miles per hour. is the wind-chill temperature. The formula cannot be
used for wind speeds below 2 mph or temperatures below or above
Write a program that prompts the user to enter a temperature between and
and a wind speed greater than or equal to 2 and displays the wind-chill tem-
perature. Use Math.pow(a, b) to compute
t a
t wc
-
58
F
41
F.
-
58
F
41
F
v 0.16 .
Here is a sample run:
Enter the temperature in Fahrenheit:
Enter the wind speed in miles per hour:
The wind chill index is -5.56707
5.3
6
 
Search WWH ::




Custom Search