java
السلام عليكم
اذا ماعليكم امرابغا حل هال سؤالين
Q1:Write an application that prompts the user for the radius of a circle and uses a
method called circleArea to calculate the area of the circle.
output
Enter the radius (negative to quit): 10
Area is 314.159265
Enter the radius (negative to quit): -1
Q2: Write method distance to calculate the distance between two points (x1, y1) and (x2, y2). All
numbers and return values should be of type double. Incorporate this method into an application that
enables the user to enter the coordinates of the points. Use -88888 as a sentinel value.
Hints:
• The distance between two points can be calculated by taking the square root of
( x2 - x1 )2 + ( y2 - y1 )2
output
Enter X1 (-8888 to stop): 1
Enter Y1: 1
Enter X2: 4
Enter Y2: 5
Distance is 5.000000
Enter X1 (-8888 to stop): -8888
|