tomy jura
Greenhorn
Posts: 3
hi to all! my name is tomislav and i got homework to do.
the objective is: "Create a class Rectangle, whose properties are the length of the page a and b (data type int), and methods of her size (a * b) and length of the diagonal (from the root (a ^ 2 + b ^ 2))"
i dont know handle the root objectives, its some kind of hard for me...so if anyone can help me, please!

tnx!!

Sagar Rohankar
Ranch Hand
Posts: 2907
1
Welcome to JR !
tomy jura wrote:i dont know handle the root objectives, its some kind of hard for me...so if anyone can help me, please!

?? Root objective? Can you explain it more? Also we like to see what you tried so far.

tomy jura wrote:tnx!!

User real word.

Rajeev Rnair
Ranch Hand
Posts: 310
1
tomy jura wrote:hi to all! my name is tomislav and i got homework to do.
the objective is: "Create a class Rectangle, whose properties are the length of the page a and b (data type int), and methods of her size (a * b) and length of the diagonal (from the root (a ^ 2 + b ^ 2))"
i dont know handle the root objectives, its some kind of hard for me...so if anyone can help me, please!

tnx!!

Hi Tomy, welcome to the Ranch
I believe you are asking a square which is a * a;

Ankit Garg
Sheriff
Posts: 9529
33
Tomy there are a few things that I would like to point out to you.

1. Your problem has nothing to do with SCJP, so I'll move this topic to the more appropriate forum. In the future please CarefullyChooseOneForum.

If you have problem calculating the root of a^2 + b^2, then look into the java.lang.Math class...

Nicola Garofalo
Ranch Hand
Posts: 308
In java there's a class called java.lang.Math that has a static method called sqrt that does exactly what you want to do (the square root):

The sqrt method returns a double

tomy jura
Greenhorn
Posts: 3
So far i do nothing becouse i must do this homework till tomorrow and i do not have time. Actually i've start this task in NetBeans. So i hope you would help me. The root, i mean a*a, yes.

Im sorry for being such newbie and dont read forum guid before using. Its my first time and i have recommendation from one of my friend for this forum.

What im asking for, is a whole java code of this task before tomorrow if possible.

Sagar Rohankar
Ranch Hand
Posts: 2907
1
tomy jura wrote:What im asking for, is a whole java code of this task before tomorrow if possible.

No one is going to write a code for you. You have to show your effort first, what you tries do far ?

Rob Spoor
Sheriff
Posts: 20669
65
tomy jura wrote:So far i do nothing becouse i must do this homework till tomorrow and i do not have time.

Then I suggest you make time and start working fast, because you should DoYourOwnHomework.

What im asking for, is a whole java code of this task before tomorrow if possible.

Then you're out of luck, because we are NotACodeMill.

That said, here are some pointers.

Create a class Rectangle

There's your start already. All you need to do is fill it in.

whose properties are the length of the page a and b (data type int)

You know how to add fields to a class, don't you? The names and data types are already specified for you. All you need to do is add them to your class, and initialize them (hint: that's what a constructor can do for you).

and methods of her size (a * b)

You should also already know how to create a method. The name is already given ("size"), and even its implementation.

and length of the diagonal (from the root (a ^ 2 + b ^ 2))

Likewise. You've already been shown how to calculate a^2 (b^2 is similar of course). + is easy enough, and you've also been shown how the root can be calculated.

With these hints you should be able to create such a class within, let's say, 30 minutes. (Experienced programmers should have it finished within 5 including equals, hashCode and toString methods ) If you still don't know how to create the class then you are simply not familiar enough with Java, and then you should have started much earlier.

Campbell Ritchie
Sheriff
Posts: 50277
80
Welcome to the Ranch

You should be able to write that class in good time to hand it in tomorrow. As people have told you, you will have to work out the methods for yourself.

Campbell Ritchie
Sheriff
Posts: 50277
80
Damn! Rob beat me to it, as he so often does But he is correct that you can complete that task in half an hour.

tomy jura
Greenhorn
Posts: 3
ok, so...

This is so far for now.

Rajeev Rnair
Ranch Hand
Posts: 310
1
Please read Rob's post carefully. Your solution is all in there. Also read Ankit's post. He explained how to do a square root.
Create a small class, add fields, add methods and add System.out.println() for seeing output etc. Do this yourself and ask any doubts. You would not learn anything if you depend on others to do your home work!

Thanks,