Livejournal
Log in
Post
Friends
My journal
reijigin
Need help with Java
Nov 24, 2008 17:15
Kay guys, here's the problem (
Read more...
)
school
,
work
Leave a comment
Comments 18
darkbunny
November 25 2008, 00:55:29 UTC
Math.max(number, otherNumber) gives the larger of two numbers.
Math.abs(number) gives the absolute value of a number*.
So...
public int largerAbsVal(int a, int b){
return Math.max(Math.abs(a),Math.abs(b));
}
*'number' in this case means short, long, int, float, or double.
Reply
jokergirl
November 25 2008, 07:56:12 UTC
This.
Reply
reijigin
November 25 2008, 08:13:49 UTC
Any advice on the quadratic one? :X
Reply
jokergirl
November 25 2008, 08:16:54 UTC
I'm not quite sure I understand your question there. What do you mean by "accept any a, b and c"? Do you mean that the datatype of the a, b, and c parameters is unknown?
;)
Reply
Thread 18
Leave a comment
Up
Comments 18
Math.abs(number) gives the absolute value of a number*.
So...
public int largerAbsVal(int a, int b){
return Math.max(Math.abs(a),Math.abs(b));
}
*'number' in this case means short, long, int, float, or double.
Reply
Reply
Reply
;)
Reply
Leave a comment