Skip to main content

Posts

Showing posts with the label Write a Java program to enter base and height of a triangle and find its area.

ads1

Java Basic

    Write a Java program to enter base and height of a triangle and find its area. Static   Sol :-  class traingle {     public static void main(String args[])     {         int base=5,height=6,area;         area = (base*height)/2;         System.out.println("The area of a Traingle is :- "+area);             }    } Output :-  Dynamic   import java.util.*; class traingle {     public static void main(String args[])     {         Scanner in = new Scanner(System.in);         System.out.println("Enter the base of a Traingle");         int base = in.nextInt();         System.out.println("Enter the height of a Traingle");         int height = in.nextInt();         int area = (base*height)/2;         System.out.println("The area of a Traingle is :- "+area);               } } output :-

ads2