Computer Science Canada find the root of one number to the other |
Author: | krishon [ Sat Sep 27, 2003 11:18 am ] |
Post subject: | find the root of one number to the other |
well for example 3^1/4 which is the same as 4 root 3....wut function would i use to do that? |
Author: | rizzix [ Sat Sep 27, 2003 11:57 am ] |
Post subject: | |
public static double Math.pow(double a, double b); Which is defined in the java.lang package.. so no imports necessary. Raises the first arg to the second, i.e: a^b |
Author: | krishon [ Sat Sep 27, 2003 6:32 pm ] |
Post subject: | |
no not that one, its something else...here let me copy the question out, maybe it should make a difference. Create a class called Number***. This class should have an instance variable, called num, that will hold an integer value that will be the basis for all operations using this object. You should have a constructor that initializes num to hold the base value. Your class should include methods that will use various methods from the Math class to do the following: a. A method that will return double the value of the num value. Call this method double(). b. A method that will return square the value of the num value. Call this method square(). c. A method that will return the square root of the num value. Call this method root(). d. A method that will take a parameter and return the quotient of the parameter divided by num rounded up to the nearest integer. Call this method divUp(). e. A method that will return the value of num to the power of a parameter. Call this method power(). i've done all but e |
Author: | Tony [ Sun Sep 28, 2003 1:11 am ] |
Post subject: | |
Math.pow(num,argument) ? |
Author: | krishon [ Sun Sep 28, 2003 9:30 am ] |
Post subject: | |
that one wuz for b.... |
Author: | rizzix [ Sun Sep 28, 2003 11:18 am ] | ||
Post subject: | |||
whats wrong with this.. you using the same method: pow. but ur using it differently (sort of). And the question does not say anything about using a method more than once.
|
Author: | krishon [ Sun Sep 28, 2003 11:19 am ] |
Post subject: | |
i dunno..maybe i interpreted the question wrong...ok i'll take ur way |
Author: | rizzix [ Sun Sep 28, 2003 11:30 am ] |
Post subject: | |
woops i think i read ur question wrong. the methods are instance methods and affect (or work on) an instance variable.. |