Area of a triangle

Area of a triangle

Problem Description


Java Program to find area of a triangle


Formula = 0.5*length*breadth


Mandatory:


1. Declare variable in float and the variable names as "length" and "breadth"

float length,breadth


2. Use Scanner class with Scanner object as "s"

Scanner s=new Scanner(System.in)


Note:


If you don't encounter mandatory testcases then the evaluation will not show 100%

Logic Test Case 1


Input (stdin)

11


13


Expected Output


71.5

Logic Test Case 2


Input (stdin)

21


27


Expected Output


283.5




CODE AREA

import java.io.*;

import java.util.Scanner;

public class TestClass {

public static void main(String[] args) { 

double l,b,f;

       Scanner in=new Scanner(System.in);

       l=in.nextDouble();

       b=in.nextDouble();

       f=0.5*l*b;

       System.out.println(""+f);

}

}

Post a comment

0 Comments