# Help with a homework problem

• March 5th, 2014, 02:39 PM
Rich0818
Help with a homework problem
I am doing an assignment that is asking for the user to put in the radius of a circle and the program figures out the area, diameter and circumference. It is using 2 different java programs to accomplish this. One with the info on how to get area, diameter and circumference and one is the demo that runs the program. I keep getting errors on my demo.
Code Java:

```// Circle Class   public class Circle { private double rad; private double Pie; private double area; private double diameter; private double circumference;     public Circle(double Radius, double PI, double Area, double Diameter, double Circumference) { Radius = rad; PI = Pie; Pie =3.14159; Area = area; Diameter = diameter; Circumference = circumference;   }```
That is the first part and the second is:

Code Java:

```import java.util.Scanner;   // Circle Demo   public class CircleDemo { public static void main(String [] args) {   System.out.println("Rich Simmerman 3/4/2014/n/n");   double circleRadius;       Scanner keyboard = new Scanner(System.in);     System.out.println("Enter the radius of the circle: "); circleRadius = keyboard.nextDouble();   [I] Circle data = new Circle(circleRadius);[/I]   System.out.println("The circle's area is " + data.getArea());   System.out.println("The circle's diameter is " + data.getDiameter());   System.out.println("The circle's circumference is " + data.getCircumference());     } }```

I am really just starting out and not sure what I'm doing.
• March 5th, 2014, 02:51 PM
Norm
Re: Help with a homework problem
Quote:

I keep getting errors
Please copy the full text of the error message and paste it here. It has important info about the errors.
• March 5th, 2014, 02:57 PM
Rich0818
Re: Help with a homework problem
Quote:

Originally Posted by Norm
Please copy the full text of the error message and paste it here. It has important info about the errors.

1 error found:
File: C:\Users\rich\Desktop\CircleDemo.java [line: 22]
Error: constructor Circle in class Circle cannot be applied to given types;
required: double,double,double,double,double
found: double
reason: actual and formal argument lists differ in length

--- Update ---

Sorry I didn't copy the whole first part of the program

Code Java:

```// Circle Class   public class Circle { private double rad; private double Pie; private double area; private double diameter; private double circumference;     public Circle(double Radius, double PI, double Area, double Diameter, double Circumference) { Radius = rad; PI = Pie; Pie =3.14159; Area = area; Diameter = diameter; Circumference = circumference;   }         public void setRad(double Radius) { rad = Radius; }       public double getRad() { return rad; }   public double getArea() { return Pie * rad * rad; }   public double getDiameter() { return rad * 2; }   public double getCircumference() { return 2 * Pie * rad; } }```
• March 5th, 2014, 02:59 PM
Norm
Re: Help with a homework problem
The compiler found a call to a constructor that did NOT have the correct args.
The compiler found: a call to a constructor that used a double
but the constructor required: double,double,double,double,double

Look at the constructor for the Circle class, make a note of the args it takes and then code the new statement that calls the constructor to use the required args.

A question: Why are these values passed to the constructor:
PI, Area, Diameter, Circumference

PI I assume is the constant. No need to pass it
The other 3 are supposed to be computed by the class
• March 5th, 2014, 03:06 PM
Rich0818
Re: Help with a homework problem
That's why I'm asking, I 'm still new to this and just starting out. Most still doesn't make sense to me yet. This is only my 3rd assignment, most of the others have been pretty simple.
• March 5th, 2014, 03:23 PM
Norm
Re: Help with a homework problem
• March 5th, 2014, 03:28 PM
Rich0818
Re: Help with a homework problem
Ok, thanks!