fork download
  1.  
  2. import java.util.*;
  3. import java.lang.*;
  4. import java.io.*;
  5.  
  6. class Ideone
  7. {
  8. public static void main (String[] args)
  9. {
  10. float a, b, c;
  11. Scanner scanner = new Scanner(System.in);
  12. System.out.println("Enter values: ");
  13. a = scanner.nextFloat();
  14. b = scanner.nextFloat();
  15. c = scanner.nextFloat();
  16.  
  17. if (a + b >= c || b + c >= a || a + c >= b) {
  18. float p = (a + b + c) / 2;
  19. float S = (float) Math.sqrt(p * (p - a) * (p - b) * (p - c));
  20. float R = (a * b * c) / (4 * S);
  21. float r = S/p;
  22. System.out.println("Radius of incircle of triangle = " + r + "\nRadius of excircle of triangle = " + R);
  23.  
  24. } else {
  25. System.out.println("Wrong input data. Triangle doesn't exist");}
  26. }
  27. }
Success #stdin #stdout 0.18s 321344KB
stdin
7.5
10
13
stdout
Enter values: 
Radius of incircle of triangle = 2.450117
Radius of excircle of triangle = 6.5236096