Skip to main content

Posts

Showing posts with the label area and volume of a box

Create one Box class and find out area and volume of a box (Using parameterized method, And method should have no return type)

Create one Box class and find out area and volume of a box (Using parameterized method, And method should have no return type). import java.util.Scanner;  public class volumeBox {  public static void main(String[] args) {  Scanner sc = new Scanner(System.in);  System.out.println("Enter the value of length: ");  double l=sc.nextDouble();  System.out.println("Enter the value of width: ");  double w=sc.nextDouble();  System.out.println("Enter the value of height: ");  double h=sc.nextDouble();  box b1=new box();  System.out.println("The area of the box is "+b1.area(l, w, h));  System.out.println("The volume of the box is "+b1.volume(l, w, h));  sc.close();  }  }  class box{  public double area(double l,double w,double h){  return 2*(l*w+l*h+h*w);  }  public double volume(double l,double w,double h){  return l*w*h;  }  } OUTPUT: Enter the value of length: 5 Enter the value of w...