S
Sphenxes
Hi Everyone
I am reading OOP Problem Solving Java. In one of its excercises It was
recommended to build a program to calculate the Area and Circumfernce of a
circle. I do like to follow the example in the book and decided to do my own
program. I got a lot of comilation errors. I do not know whether these
errors are due to design failure or simple declaration errors.
/**
* The Circle Class program
* Oject Oriented Programming
* Java, Java, Java
* p. 99
*/
class TestCircle {
Circle circleOne = new Circle();
circleOne.area(10, 15);
circleOne.circumference(10, 2);
}
public class Circle{
public static void main (String arrgv[]) throws Exception{
//private float diameter= 10;
float area;
float circumference;
final double Pi=2.323;
float r; //radius
//r = diameter/2;
double area(float r, double Pi){
area = Pi*r*r;
System.out.println("The area of the Circle := " + area);
return;
}
double circumference(float r, double Pi){
circumference = 2*Pi*r;
System.out.println("The Ciruference of the Circle is := " +
circumference);
return;
}
}
}
Comilation Errors:
Circle.java [11:1] <identifier> expected
circleOne.area(10, 15);
^
Circle.java [12:1] <identifier> expected
circleOne.circumference(10, 2);
^
Circle.java [27:1] ';' expected
double area(float r, double Pi){
^
Circle.java [11:1] package circleOne does not exist
circleOne.area(10, 15);
^
Circle.java [12:1] package circleOne does not exist
circleOne.circumference(10, 2);
^
Circle.java [27:1] area is already defined in main(java.lang.String[])
double area(float r, double Pi){
^
6 errors
Errors compiling Circle.
I am reading OOP Problem Solving Java. In one of its excercises It was
recommended to build a program to calculate the Area and Circumfernce of a
circle. I do like to follow the example in the book and decided to do my own
program. I got a lot of comilation errors. I do not know whether these
errors are due to design failure or simple declaration errors.
/**
* The Circle Class program
* Oject Oriented Programming
* Java, Java, Java
* p. 99
*/
class TestCircle {
Circle circleOne = new Circle();
circleOne.area(10, 15);
circleOne.circumference(10, 2);
}
public class Circle{
public static void main (String arrgv[]) throws Exception{
//private float diameter= 10;
float area;
float circumference;
final double Pi=2.323;
float r; //radius
//r = diameter/2;
double area(float r, double Pi){
area = Pi*r*r;
System.out.println("The area of the Circle := " + area);
return;
}
double circumference(float r, double Pi){
circumference = 2*Pi*r;
System.out.println("The Ciruference of the Circle is := " +
circumference);
return;
}
}
}
Comilation Errors:
Circle.java [11:1] <identifier> expected
circleOne.area(10, 15);
^
Circle.java [12:1] <identifier> expected
circleOne.circumference(10, 2);
^
Circle.java [27:1] ';' expected
double area(float r, double Pi){
^
Circle.java [11:1] package circleOne does not exist
circleOne.area(10, 15);
^
Circle.java [12:1] package circleOne does not exist
circleOne.circumference(10, 2);
^
Circle.java [27:1] area is already defined in main(java.lang.String[])
double area(float r, double Pi){
^
6 errors
Errors compiling Circle.