aspose file tools*
The moose likes Beginning Java and the fly likes help please! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help please!" Watch "help please!" New topic
Author

help please!

tomy jura
Greenhorn

Joined: May 05, 2010
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

Joined: Feb 19, 2008
Posts: 2902
    
    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.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

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;


SCJP6, SCWCD5, OCP-JBCD5, OCE-JWSD6 OCE-JPAD6 , OCM-JEA5 1,OCM-JEA5 2,3 - Brainbench certifications: J2EE, Java2, Java2-NonGUI, JSP, SQL2000 Admin, SQL2000 Programming , Brainbench certified Java Programmer, Computer Programmer, Web Developer, Database Administrator
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9303
    
  17

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.
2. Please UseAMeaningfulSubjectLine when you start a topic. "Please Help" doesn't necessarily tells what the question is about.
3. At javaranch we encourage people to DoYourOwnHomework, we can help you with your problem, but don't expect any ready-made answers.

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


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
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


Bye,
Nicola
tomy jura
Greenhorn

Joined: May 05, 2010
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

Joined: Feb 19, 2008
Posts: 2902
    
    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

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38865
    
  23
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

Joined: Oct 13, 2005
Posts: 38865
    
  23
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

Joined: May 05, 2010
Posts: 3
ok, so...


This is so far for now.
Rajeev Rnair
Ranch Hand

Joined: Mar 22, 2010
Posts: 308

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,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help please!