Hi all, I have an assignment to hand in tomorrow for programming and would appreciate any help that is given. I have done a couple of years programming with VB but java is like on a completely level compared to it.
Ok, so basically I have to program an application that will have a constructor to create a circle with a unit radius. The method will then return
- The radius
- The area
- The circumference
- The total area of the object and another circle
- The total circumference of the object and another circle
I’ve practically finished with the program but keeps giving me 1 error at the end that I can’t seem to solve.
My code for the method is here:
//Circle
//An application that can create a circle using the radius given from the user and to calculate the
//area, circumference of it and to display it to the user.
import java.io.*;
public class Circle {
public int radiusInt;
public String radiusStringInput;
public void main(String[] args) throws IOException {
// Create BufferedReader instance to enable input from keyboard
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader keyboardInput = new BufferedReader(input);
System.out.println("please enter the radius:");
radiusStringInput = keyboardInput.readLine();
radiusInt = Integer.parseInt(radiusStringInput);
}
public Circle(int x, int y,int r){
r = radiusInt;
x = radiusInt *2;
y= radiusInt * 2;
}
public int radiusInt(){
radiusInt = radiusInt;
return (radiusInt);
}
public Double getCircumference(){
Double Circ = 2 * 3.14 * radiusInt;
return (Circ);
}
public Double getArea(){
double Area = 3.14 * radiusInt * radiusInt;
return (Area);
}
}
[B]My code for the constructor is here:[/B]
import java.io.*;
public class CircleApp {
public static void main(String[] args) {
Circle Circle = new Circle(Circle.radiusInt);
System.out.println("Circumference is " + Circle.getCircumference());
System.out.println("The Area is:" + Circle.getArea());
System.out.println("The Radius is:" + Circle.radiusInt);
int radiusB = 5;
Circle CircleB = new Circle(radiusB);
double circleTotalArea = 3.14* radiusB * radiusB;
double circleTotalCircumference = 2 * 3.14 * radiusB;
System.out.println("Circumference is " + Circle.getCircumference());
System.out.println("The Area is:" + Circle.getArea());
System.out.println("The Radius is:" + Circle.radiusInt);
System.out.println("The Total Area is:" + circleTotalArea);
System.out.println("The Circumference is:" + circleTotalCircumference);
}
}