IF someone can write this code out for me so i can use it as an example for the rest of my problems and question i have to do I would really appreciate it alot. and no this question is not Homework what so ever I am a visual person i need an example of a program so I can piece together several other questions together to get own answers... Thank you for who ever can help me I can solve the rest visually.

write a superclass encapsulating a circle; this class has one attribute representing the radius of the circle. it has methods returning the perimeter and the area of the circle. This class has a subclass, encapsulating a cylinder. a cylinder has a circle as it's base, and another attribute, its length ; it has two methods, calculating the return its area and volume. You also need to include a client class to test these two classes

Recommended Answers

All 4 Replies

and no this question is not Homework what so ever

How do you expect anyone to buy that when you are obviously in a Java class currently?

Show some effort and at least make a start on it or ask specific questions about what you are confused about.

Well, this really sounds like a typical homework assignment to me, so I'm not going to provide the full solution to you -just in case.. This is some pretty fundamental java you are asking about, and if you want to start programming, this is something you must learn to figure out by yourself. I can, however, help you with pushes in the right direction until we've solved this exercise.

What have you got so far? Do you know how to create a class? A method? Where do you start getting problems?

Regards,
Emil Olofsson

THis is whats wrong with the world no trust. Just asked for help, because the examples for inheritence that I have looked in for my book does not help me at all. And yes I am in a java class..... teaching myself. and out of all the questions or problems i have to do i picked the one that i dont need to do. I picked this problem so i could get an example with the test client involved cuase i dont see the point of it. Thats all i wanted was an actual problem done out for myself so that I can piece my other questions together off of that problem but no.... there is no trust.

I really wonder where we are going to be in 50 years

what ever I got it thanks for the help, I appreciate it.

There are thousands of examples of inheritance on the internet. You could read as many as you like.

You could also make a stab at it yourself and ask questions about the parts that you struggle with. We encourage that here.

Asking someone to work one of the problems from your book for you "just so you can see it" without making even the slightest effort yourself is just lazy and has all the appearance of cheating on an assignment.

All your indignation won't change that and it won't change where we'll be in 50 years.

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.