fork download
  1. //Jason B. Bendong
  2.  
  3. import java.util.Scanner;
  4.  
  5. class CircleAreaIO2
  6. {
  7. public static void main (String[] args)
  8. {
  9. Scanner scan = new Scanner( System.in );
  10.  
  11. int radius;
  12. double areaCircle;
  13.  
  14. System.out.print( "Enter radius: -35. " );
  15. radius = scan.nextInt();
  16.  
  17. areaCircle = Math.PI*Math.pow(radius,2);
  18.  
  19. if ( radius < 0 ){
  20. System.out.println("Error: must not be negative number");
  21. }else{
  22. System.out.println("Area of the circle is: " + areaCircle);
  23. }
  24. }
  25. }
Success #stdin #stdout 0.12s 49572KB
stdin
-35
stdout
Enter radius: -35. Error: must not be negative number