I am trying to write a program that will give me the volume of a cylinder when I run it. I already have a Circle class that computes the area of a circle. I am also using a seperate program to handle the input and output. Could someone tell me what I am doing wrong with my program?

public class Cylinder
{
// calls up and creates an object from the Circle class

Private Circle base;
Private double Height;

//Constructor
Public Cylinder(double h, double r)
{
// creates object from cirle class
Circle base = new circle(r);
height = h;
}
public double getVolume()
{
return CircleBase.area * height;
}
}

What are you having a problem with? You told us what your program is supposed to do, and that its not working, but you never told us exactly what part isn't working.

I am sorry, I am new XP

i keep getting "Reached end of file while parsing" and all the brackets are there. What am I doing wrong!

looking at your code... did you copy and paste that? if yes then, you need to ensure that "public" and "private" modifiers are in lowercase.

Private and Public should be changed to private and public. They are supposed to be lowercase - I think it will give you a compiler error otherwise.

Private and Public should be changed to private and public. They are supposed to be lowercase - I think it will give you a compiler error otherwise.

that's what i said...and yes it will definitely give you a compiler error

Oh, sorry man. Didn't mean to step on your toes, I don't know why I didn't read that part of your response or didn't register it or something.

Edit: Also, I don't know why somebody would down vote my post. I am a regular poster here and I never 'repeat responses' or anything like that - I don't even respond if I have nothing to contribute - this was obviously an accident.

Thanks you guys. I fixed the cases, but I still get the "reached end while parsing error.

One thing I should note is that when I do get that error I also get

Public class cylinder>
^

directly underneath it

I don't see any other errors. . can you re-post your updated code? It seems like it still thinks your case is wrong somewhere.

when you created your Circle class you had your "circle" in lowercase it should be in Uppercase.

Circle base = new Circle(r);

here is my new code(with all of your suggestions) and the code for my circle class

public class Cylinder


// calls up and creates an object from the Circle class	

	private Circle base;	
	private double Height;
{
//Constructor	
	public Cylinder(double h, double r)
	{
// creates object from cirle class	
	Circle Base = new Circle(r);
	height = h;
	}
	
public double getVolume()
	{
	return CircleBase.area * height;
	}
}
public class Circle
{
  private double radius;

  public Circle(double r)
  {
    radius = r;
  }

  public double getArea()
  {
    return Math.PI * radius * radius;
  }
}

private double Height;

It looks like height should be lowercase there, according to the rest of your class. Btw, making variables lowercase to start with is a convention in Java.

I suggest you use a good JAVA editor and/or an IDE (Integrated Development Environment)...Eclipse, NetBeans or BlueJ to name a few. These errors are easily recognized by these editors and they can give you possible solutions to your errors too. It can even remind you of some JAVA conventions as what BestJewSinceJC has pointed out. If you are really serious in your programming, I strongly suggest using an IDE.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.