Object Oriented program question

Discussion in 'Java' started by jon3484, Jul 19, 2005.

  1. jon3484

    jon3484 Guest

    It's my first time running an object oriented program (Circleprogram.java
    and Circle.class), and I have a few questions.

    Do you have to compile the actual java program (in my case
    Circleprogram.java)? I actually tried to compile the program, but still
    got the error "error: cannot read:Circleprogram.java". I had someone
    proof read my coding, and he spotted some errors, but I corrected them,
    and still having problem.
     
    jon3484, Jul 19, 2005
    #1
    1. Advertising

  2. jon3484

    Wayne Guest

    jon3484 wrote:
    > It's my first time running an object oriented program (Circleprogram.java
    > and Circle.class), and I have a few questions.
    >
    > Do you have to compile the actual java program (in my case
    > Circleprogram.java)? I actually tried to compile the program, but still
    > got the error "error: cannot read:Circleprogram.java". I had someone
    > proof read my coding, and he spotted some errors, but I corrected them,
    > and still having problem.
    >
    >
    >

    At the command line prompt you must make sure the current directory
    is where the program is. The prompt usually tells you where you
    are. If your program is in "My Documents" and your prompt is
    "C:\>" Then you get this error. You can change the current
    directory with the "cd" command.

    You can also get this error if you make a typo in the program
    name. You can type "dir" to see the names. In your
    case you should see "Circleprogram.java", and not
    "CircleProgram.java" or "Circleprogram.java.txt"

    It is likely that the classname is really "CircleProgram". Note
    the capital letters!

    Hope this helps!

    -Wayne
     
    Wayne, Jul 19, 2005
    #2
    1. Advertising

  3. jon3484

    jon3484 Guest

    Thanks, I finally got it compiled, however now I'm getting errors about no
    definition class. I'm getting the same message for both my class file and
    the actual program.

    import javax.swing.JOptionPane;

    public class Circleprogram
    {
    public static void main (String[]args)
    {
    double number, area, circumference, diameter, radius;
    String input;

    Circle info = new Circle();

    input= JOptionPane.showInputDialog("What is the radius");

    number = Double.parseDouble(input);
    info.setRadius(number);

    radius= info.getRadius();
    area = info.getArea();
    diameter = info.getDiameter();
    circumference = info.getCircumference();

    JOptionPane.showMessageDialog(null, "The area is" + area +
    ", the circumference is" + circumference +
    ", the diameter" + diameter + ", and the radius is " +
    radius);

    System.exit(0);
    }
    }

    this is the actual program
     
    jon3484, Jul 19, 2005
    #3
  4. jon3484

    hilz Guest

    hilz, Jul 19, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Abs
    Replies:
    1
    Views:
    1,098
    Thomas Weidenfeller
    May 11, 2004
  2. SSG
    Replies:
    18
    Views:
    616
  3. Replies:
    2
    Views:
    482
    Bruno Desthuilliers
    May 26, 2008
  4. rolo
    Replies:
    3
    Views:
    197
    Robert Klemme
    Apr 9, 2004
  5. J W
    Replies:
    2
    Views:
    409
Loading...

Share This Page