1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Java hw help

Discussion in 'Java' started by cvillejin, Mar 21, 2011.

  1. cvillejin

    cvillejin New Member

    Hi, I'm new to Java and I have no idea how to do this problem. I don't know what loops are or how to use them.

    5. In mathematics, exponentiation of an is a multiplied by itself n times. For instance, 53 is 5*5*5, or 125. Define a method so it may be called using the following statement and finds the correct exponential operation:
    [FONT=&quot]int result = exponent(5,3);[/FONT]
    You must use a loop in your method. Using the java.lang.math method pow() is not allowed. You can assume that the exponent is a positive, whole number. Note that the ^ operator does not perform exponentiation.
  2. cvillejin

    cvillejin New Member

    you can call the method what you want but I'm going to call it expo for now

    public int expo(int n, int x){

    int z, y;

    for(z=0: z<x; z++){
    return y;

    is this correct?

Share This Page