Object Oriented program question

J

jon3484

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.
 
W

Wayne

jon3484 said:
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
 
J

jon3484

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top