Hello,
Stuck on one line of code, tried everything but could not make any progress. Please help. Thanks in advance. The problem is on line 39 which is:
slant_height = SphericalCone1.getSlantHeight( radius, cone_height) ; TheNetBeans IDE6.8 displays the error message:
Can not find symbol: class SphericalCone
But SpericalCone class compiles ok and is the same directory as this program.
The text at the beginning of this window, said NOT to use code tags, because Java code will highlighted. Hope I got that right.
import java.util.Scanner;
import java.util.InputMismatchException;
/**
* Spherical Cone using Methods
*
* Eric Allione
*/
public class AllioneA08_Tentative{
//
double cone_height ;
double radius ;
//
public void main(String[] args) {
//
double slant_height, volume, surface_area ;
//
try {
Scanner keybd = new Scanner(System.in);
//
// Spherical Cone Slant height
System.out.print("Enter Spherical Cone Height: ");
cone_height = keybd.nextDouble();
//
// Spherical Cone Base Radius
System.out.print("Enter Spherical Cone Base Radius: ");
radius = keybd.nextDouble();
//
}catch (NumberFormatException exception)
{
System.out.println("You must enter a number. Please try again.");
}
finally
{
//
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// Create a Spherical Cone Object
SphericalCone SphericalCone1 = new SphericalCone( radius, cone_height ) ;// Won't work???
//
// SphericalCone SphericalCone1 ; // Generate an instance of SphericalCone class
// SphericalCone1 = new SphericalCone( radius, cone_height ) ; // Won't work????
//
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//
// Compute slant height
// slant_height = Math.sqrt( r*r + c*c ) ;
slant_height = SphericalCone1.getSlantHeight( radius, cone_height) ;
//
// Compute Volume
// vol = (2.0D/3.0D)*Math.PI*s*s*( slant_height - c ) ;
volume = SphericalCone1.getVolume( radius, cone_height ) ;
// Compute Sufrace Area
// surface_area = Math.PI*s*( 2.0D*( slant_height - c ) + r ) ;
surface_area = SphericalCone1.getSurfaceArea( radius, cone_height ) ;
//
//print results
System.out.println( " For a spherical cone with radius "
+ radius + " and height " + cone_height );
System.out.println( " Slant Height = " + slant_height );
System.out.println( " Volume = " + volume );
System.out.println( " Surface area = " + surface_area );
//
}
// end of main
}
// end of top class
}
//
// Spherical Cone
// Eric Allione
// AllioneA09
//
public class SphericalCone
{
private double r ;
private double c ;
private double s ;
private double vol ;
private double surface_area ;
public static final double two = 2.0D ;
public static final double three = 3.0D ;
//
// Set up the parameters via the input start_r and start_c
public SphericalCone ( double start_r, double start_c )
{
r = start_r ;
c = start_c ;
s = Math.sqrt( r*r + c*c) ;
surface_area = Math.PI*s*( two*( s - c ) + r ) ;
vol = ( two / three )*Math.PI*s*s*( s - c ) ;
}
// accessor
public double getSlantHeight()
{
return s ;
}
// accessor
public double getVolume()
{
return vol ;
}
// accessor
public double getSurfaceArea()
{
return surface_area ;
}
//
}
// End of Spherical_Cone Class