Help with a newbies program
I have a program that that does calculation of afew didfferent areas.
The first three only take one user key imput but the third requires two user inputs for height and radius of a cylinder. I am unable to get the cal.
I have insert to prints to make sure the program is accepting the two key inputs, but cannot get them to work in the equation.import TerminalIO.*;
class FindAreaDemo{
publicstaticvoid main ( String[] args ){
KeyboardReader keyEntry =new KeyboardReader();
FindArea square =new FindArea();//made a new object from FindArea
square.setLength
(keyEntry.readDouble("\n\tEnter length of sides of the square: "));
System.out.println ("\t\tArea of the square is " + square.getAreaSquare());
FindArea cube =new FindArea();//made a new object from FindArea
cube.setCube
(keyEntry.readDouble("\n\tEnter length of sides of the Cube: "));
System.out.println ("\t\tArea of the cube is " + cube.getAreaCube());
SphereArea circle =new SphereArea();//made a new object from FindArea
circle.setCircle
(keyEntry.readDouble("\n\tEnter The radius for the cicle: "));
System.out.println ("\t\tArea of the circle is " + circle.getareaCircle());
//**************************************************************************
SphereArea height =new SphereArea();
height.setHeight1
(keyEntry.readDouble("\n\tEnter height of the cylinder: "));
System.out.println ("\t\t\t\t height is " + height.getHeight1());
SphereArea radius =new SphereArea();
radius.setRadius1
(keyEntry.readDouble("\n\tEnter radius of the cylinder: "));
System.out.println ("\t\t\t\t radius is " + radius.getRadius1());
SphereArea cylinder =new SphereArea();
System.out.println ("\n\t\tArea of a cylinder is " + cylinder.getareaCylinder());
}
}
the two class I madepublicclass SphereArea{// begin a new class
//public static double classSphereArea; //class variable
finalprivatedouble PI = (double)3.14;//Object variable Constant
finalprivatedouble SPCONSTANT2 = 2.0;//Object variable Constant
//corrected my Constant to so that it now is really a constant
privatedouble radius;//Object variable
privatedouble height;//Object variable
privatedouble areaCircle;//Object variable
privatedouble areaCylinder;//Object variable
privatedouble height1;
privatedouble radius1;
//corrected my two variables so that they are private now and not public areaCube & areaSquare
//*******************************************************
publicvoid setCircle(double radius){
areaCircle = (PI*(radius * radius));// surface area = 4pr2
}
publicdouble getareaCircle(){
return areaCircle;
}
//*******************************************************
publicvoid setHeight1 (double height){
height1 = height;
}
publicdouble getHeight1(){
return height1;
}
//*******************************************************
publicvoid setRadius1 (double radius){
radius1 = radius;
}
publicdouble getRadius1(){
return radius1;
}
//*******************************************************
//The entire formula for the surface area of a cylinder is 2pr2 + 2prh
publicvoid setareaCylinder (double areaCylinder){
areaCylinder = (SPCONSTANT2*PI*(radius1 * radius1) + (SPCONSTANT2 * PI * radius1 * height1));
}
publicdouble getareaCylinder(){
return areaCylinder;
}
}
ublicclass FindArea{// begin a ne class
//public static double classFindArea; //class variable
privatedouble length;//Object variable
finalpublicdouble CUBE6 = 6.0;//Object variable Constant
// corrected my Constant to so that it now is really a constant
privatedouble areaCube;//Object variable
privatedouble areaSquare;//Object variable
publicvoid setLength(double length){
areaSquare = length * length;
}
publicdouble getAreaSquare(){
return areaSquare;
}
publicvoid setCube(double length){
areaCube = length * length * CUBE6;
}
publicdouble getAreaCube(){
return areaCube;
}
}//end class

