Note that there are some explanatory texts on larger screens.

plurals
  1. POProgram running in NetBeans but not command prompt
    text
    copied!<p>I am trying to design and implement a Java class to represent a 3-D geometric shape. The class should contain a constructor, appropriate data fields and methods to return the volume of the shape, and the surface area of the shape and any other methods that seem to make sense for your shape.</p> <p>However, I got everything to work fine in Net Beans, but when I try to run it in the command prompt I receive:</p> <pre><code>error package Cube doesn't exist error cannot find symbol </code></pre> <p>both of these error are referring to the class cube</p> <p>My code is as follows.</p> <pre><code>package cube; public class Cube { private double side = 0.0; public Cube(){//begin constructor side = 1.0; }//end constructor public void setSide (double length) {//begin method side = length; }//end method public double getSide () {//begin method return side; }//end method public double calculateVolume() { double volume2 = side * side * side; return volume2; } // end method public double calculateSurfaceArea() { double area = 6 * (side * side); return area; } // end method }//end class package randygilmanhw4; import java.util.Scanner; import cube.Cube;//imports class Cube public class RandyGilmanHW4 { public static void main(String[]args) {//begin main //Display welcome message System.out.println("Hello Welcome to Randy's Cube"); System.out.println(" Calculator Program"); System.out.println(""); Cube one = new Cube(); //declare variables within main double area; double volume2; double side1; Scanner input = new Scanner(System.in); System.out.println("Please enter a length of the side of the cube in cm: "); side1 = input.nextDouble(); one.setSide(side1); volume2 = one.calculateVolume(); System.out.printf("Cube's volume is: %4.2f cm^3", volume2);// OUTPUT System.out.println("\n"); one.setSide(side1); area = one.calculateSurfaceArea(); System.out.printf("Cube's surface area is: %4.2f cm^2 ", area);// OUTPUT } // end main }//end class </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload