Q:

Java program to find Area of Triangle

0

Java program to find Area of Triangle

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Area of Triangle using Java program

//Java program to find Area of Triangle.
 
import java.util.*;
 
public class AreaTriangle{
 
     public static void main(String []args){
        double base,height,area;
         
        Scanner sc=new Scanner(System.in);
         
        //Read Length and Width of Triangle
        System.out.print("Enter Base Widht: ");
        base=sc.nextDouble();
        System.out.print("Enter Height: ");
        height=sc.nextDouble();
         
        //Calculate Area
        area = (base*height)/2;
         
        //Print Result
        System.out.println("Area of Triangle: " + area);    
         
     }
}

Output

    
    me@linux:~$ javac AreaTriangle.java 
    me@linux:~$ java AreaTriangle 

    Enter Base Widht: 2.3 
    Enter Height: 32.2
    Area of Triangle: 37.03

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Core Java Example programs for Beginners and Professionals

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Java program to find Area of Rectangle... >>
<< Java program to print Fibonacci Series...