Hi friends, welcome back to Java Code Online, the Java code that is discussed today, finds the area and Perimeter of a rectangle depending on the length and width of the rectangle. When you run this Java Code, then provide the length and width of the rectangle as the input arguments yo the file.
The Java code for finding the Area and Permiter of Rectangle is given below:-
import java.io.IOException;
public class AreaPerimeterRectangle {
public static void main(String[] args) throws NumberFormatException, IOException {
System.out.println("Enter the length and width of the rectangle: ");
float length = Float.parseFloat(args[0]);
float width = Float.parseFloat(args[1]);
System.out.println("Area of the Rectangle is: "+length*width);
System.out.println("Perimeter of the Rectangle is: "+2*(length+width));
}
}
For more information on Java, kepp buzzing Java Code Online.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.