Algorithm Sample - Area of a Triangle


package algorithmsample6;

import java.util.Scanner;

/**
 *
 * @author Nurhak
 */
public class AlgorithmSample6 {

    public static void main(String[] args) {
        int base = 0;
        int height = 0;
        double area = 0;
        String data = "";

        try {
            Scanner scan = new Scanner(System.in);
            System.out.println("Please enter the base value(mm).");
            data = scan.nextLine();
            base = Integer.parseInt(data);

            System.out.println("Please enter the height value(mm).");
            data=scan.nextLine();
            height = Integer.parseInt(data);

            area = (base * height) / 2;
            System.out.println("Area of the triangle is: " + area + " mm2");

        } catch (Exception e) {
            System.err.println("Please enter an integer value!");
        }
    }
}

Comments

Popular posts from this blog

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Solution for "Can not obtain Oracle client information from registry"