4:00 am - Tuesday February 20, 2018

Java Example Program for area of right angle triangle

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

/**
* @description: Area of right angled triangle program.
* @author: Arun
*/
import java.util.Scanner;

public class R_angle {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("\nEnter the Width: ");
double width = scan.nextDouble(); // reads and converts the value into
// double
System.out.print("\n");
System.out.print("Enter the Height: ");
double height = scan.nextDouble(); // reads and converts the value into
// double
System.out.print("\n");
double area = 0.5 * height * width; // Area calculation
System.out.println("Area of the Right Angled Triangle is: " + area); // Prints
// the
// area
// value
}
}

Output:

Enter the Width: 10

Enter the Height: 5

Area of the Right Angled Triangle is: 25.0

Filed in: Z-A All Java Codes

Comments are closed.