fork(9) download
  1. //package testjava;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6. public static void main(String[] args) {
  7. Scanner input = new Scanner(System.in);
  8. System.out.println("Nhap vao canh a: ");
  9. int a = input.nextInt();
  10. System.out.println("Nhap vao canh b: ");
  11. int b = input.nextInt();
  12. System.out.println("Nhap vao canh c: ");
  13. int c = input.nextInt();
  14. float p = (a + b + c) / 2;
  15. if (((a + b) > c) && ((b + c) > a) && ((a + c) > b)) {
  16. System.out.println("Dien tich tam giac la:"
  17. + (Math.sqrt(p * (p - a) * (p - b) * (p - c))));
  18. } else
  19. System.out.println("Khong phai la tam giac");
  20. }
  21. }
  22.  
Success #stdin #stdout 0.1s 380608KB
stdin
3 4 5
stdout
Nhap vao canh a: 
Nhap vao canh b: 
Nhap vao canh c: 
Dien tich tam giac la:6.0