Write a java program to print the nested methods to perform mathematical operations

Write a java program to print the nested methods to perform mathematical operations. This is a Java program that demonstrates method nesting. Nesting of methods occurs when a Java method calls another method in the same class.Fill in the blanks with length, width, and height. After that, we call the volume method for the first time. The area method is derived from the volume technique, while the perimeter technique is derived from the area method. As a result, the perimeter, area, and volume of a cuboid are computed.

import java.util.Scanner;
public class Main
{
int perimeter(int l, int b)
{
int pr = 12 * (l + b);
return pr;
}
int area(int l, int b)
{
int pr = perimeter(l, b);
System.out.println("Perimeter"+pr);
int ar = 6 * l * b;
return ar;
}
int volume(int l, int b, int h)
{
int ar = area(l, b);
System.out.println("Area"+ar);
int vol ;
vol = l * b * h;
return vol;
}
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter length of the cuboid");
int l = s.nextInt();
System.out.print("Enter breadth of the cuboid");
int b = s.nextInt();
System.out.print("Enter height of the cuboid");
int h = s.nextInt();
Main obj = new Main();
int vol = obj.volume(l, b, h);
System.out.println("Volume"+vol);
}
}

 

Output:

Enter length of the cuboid 34
Enter breadth of the cuboid 34
Enter height of the cuboid 34
Perimeter 816
Area 6936
Volume 39304