Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Lesson7;
- /**
- * Java Start. Group 77. Home work. Lesson 7. Task 3 (CircleArea).
- *
- * @author Khilchenko Sergii
- * @version 0.1.0 05.15.2018
- *
- */
- public class CircleArea {
- public static void main(String[] args) {
- System.out.println("CircleArea");
- double radius = -10;
- System.out.println("RADIUS: " + radius );
- System.out.println("Result: " + circleArea(radius));
- }
- public static double circleArea(double radius) {
- if (radius <= 0) {
- throw new IllegalArgumentException(" INPUT radius 0 <= ");
- }
- //return Math.PI * radius * radius;
- return Math.PI * Math.pow(radius, 2);
- }
- }
- /*
- - - - - - - - - - - - - - - - - - -
- TEST 1
- CircleArea
- RADIUS: 10.0
- Result: 314.1592653589793
- Process finished with exit code 0
- - - - - - - - - - - - - - - - - - -
- TEST 2
- CircleArea
- RADIUS: 20.0
- Result: 1256.6370614359173
- Process finished with exit code 0
- - - - - - - - - - - - - - - - - - -
- TEST 3
- CircleArea
- Exception in thread "main" java.lang.IllegalArgumentException: INPUT radius 0 <=
- at Lesson7.CircleArea.circleArea(CircleArea.java:22)
- at Lesson7.CircleArea.main(CircleArea.java:17)
- RADIUS: -10.0
- Process finished with exit code 1
- - - - - - - - - - - - - - - - - - -
- */
Add Comment
Please, Sign In to add comment