Algorithm Sample - Area and Perimeter of a Rectangle


package algorithmsample5;

import java.util.Scanner;

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

    public static void main(String[] args) {
        double side1 = 0;
        double side2 = 0;
        double area = 0;
        double perimeter = 0;
        String value = "";

        try {
            Scanner scan = new Scanner(System.in);
            System.out.println("Enter the length(mm) of first side.");
            value = scan.nextLine();
            side1 = Double.parseDouble(value);

            System.out.println("Enter the length(mm) of second side.");
            value = scan.nextLine();
            side2 = Double.parseDouble(value);

            area = side1 * side2;
            perimeter = (side1 + side2) * 2;

            System.out.println("Area : " + area + " mm2 and Perimeter : " + perimeter + " mm");
        } catch (Exception e) {
        }
    }
}

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"