*/ package calculaterectangle; /** * * @author Janie */ import java.util.Scanner; public class CalculateRectangle { //class fields private static int length; private static int width; private static int height; private static int p; private static int a; private static int v; //constructor public CalculateRectangle (){ length = 0; width = 0; height = 0; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { System.out.print("Enter length of rectangle : "); String length = sc.next(); System.out.print("Enter width of rectangle : "); String width = sc.next(); System.out.print("Enter height of rectangular prism : "); String height = sc.next(); //method p = Perimeter.perimeter.setPerimeter(perimeter); a = Area.area.setArea(area); v = Volume.volume.setVolume(volume); System.out.println("perimeter: " + p + "\n"); System.out.println("Base Area: " + a + "\n"); System.out.println("Volume : " + v + "\n"); System.out.print("Continue? (y/n): "); choice = sc.nextLine(); System.out.println(); }} public static class Perimeter extends CalculateRectangle { //class fields private int perimeter; static int p = 0; //constructor public Perimeter () { super(); } public class perimeter extends Perimeter { //constructor public perimeter () { super(); } //method public void setPerimeter(){ perimeter = 2 * (length + width); p = perimeter; } } } public static class Area extends CalculateRectangle { //class fields private int area; static int a = 0; //constructor public Area () { super(); } public class area extends Area { //constructor public area () { super();} //method public void setArea() { area = length * width; a = area; } } } public static class Volume extends CalculateRectangle { //class fields private int volume; static int v = 0; //constructor public Volume () { super(); } public class volume extends Volume { //constructor public volume() { super();} //method public void setVolume() { volume = length * width * height; v = volume; } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)