Java program to Find Area of triangle

 Program- 


import java.util.Scanner;

public class Main

{

public static void main(String[] args) 

{

    Scanner sc=new Scanner(System.in);

System.out.println("Enter breadth of triangle");

int b=sc.nextInt();

System.out.println("Enter Height of triangle");

int h=sc.nextInt();

int ans,d;

d=b*h;

ans=d/2;

System.out.println("Area of triangle is : "+ans);

}

}


Output:-
Enter breadth of triangle
12
Enter Height of triangle
21
Area of triangle is : 126


Comments

All time Best Post

Write a program that declares a class named Person. It should have instance variables to record name, age and salary. Use new operator to create a Person object. Set and display its instance variables.

IMAGE CRUD OPERATION USING EXPRESS MONGOOSE MULTER

connect websocket to binance api and store t he true value in the db

CRUD APP WITH SORT IN NODE EXPRESS AND MONGODB

express session login system using node express mongodb

how to delete image from the folder directly from a Request (MULTER)

calculate rsi

java program for 1 to 10 print using while loop

How to fetch last one minute volume of BTC in CCXT Nodejs.