Answer to Question #331286 in Java | JSP | JSF for Angge

Question #331286

a java program that will compute the surface area and volume of a cube using class

1
Expert's answer
2022-04-20T12:40:29-0400



import java.util.Scanner;
//Implement class Cube
class Cube
  {
    private double a;
    public Cube()//Default constructor
    {
      this.a=0.0;
    }
    public Cube(double _a)
    {
      this.a=_a;
    }
    //Calc volume  a*a*a
    public double Volume()
    {
      return a*a*a;
    }
    public double TotalSurfaceArea()
    {
      return 6*a*a;
    }
    public double CurveSurfaceArea()
    {
      return 4*a*a;
    }
    
  }
class Main {
  
  public static void main(String[] args) {
    System.out.print("Please enter inches each side(a): ");
    Scanner cin=new Scanner(System.in);
    double a=cin.nextDouble();
    Cube cb=new Cube(a);
    System.out.println("Total Surface Area: "+cb.TotalSurfaceArea());
    System.out.println("Curve Surface Area: "+cb.CurveSurfaceArea());
    System.out.println("Volume : "+cb.Volume());
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS