Calculate area of a Triangle in JAVA - 👑 सार्थक मुंड S3 🤴🏻

Calculate area of a Triangle in JAVA

banner

Write a program (WAP) in JAVA to read two numbers from keyboard(User Input) and calculate the area of a Triangle.

import java.util.Scanner;
class AreaOfTriangle
{
   public static void main(String[] args)
    { 
      Scanner s= new Scanner(System.in);
      
      System.out.println("Enter Base of the triangle (b):");
      double b= s.nextDouble();

      System.out.println("Enter Height of the triangle (b):");
      double h= s.nextDouble();

      double area=(b*h)/2;
      System.out.println("Area of Triangle is: " + area);    
   }
}

Try it Yourself ➠
output

 

Note :-

1. You can also write "double area=.5*b*h"

Must Read :-
  1. Blogger Tutorial
  2. C Programs
  3. C++ Programs
  4. Java Programs
  5. Python Programs
  6. Programming Notes 
  7. Questions & Answers
  8. My Codes : HTML, CSS & JS
  9. All Subject Notes
Previous article
Next article

1 Comments

Articles Ads

Articles Ads 1

Articles Ads 2

Advertisement Ads