• 01-18-2013, 03:49 PM
Aries.
Sample output :

Enter first number : 2
Enter second number : 3

// This is the process how we get the 8 = 2 * 2 * 2

I'm having a problem with this because I have no idea when using the loop. Everytime I try it always "Error" .

I'm so thankful if you will help me guys.
• 01-18-2013, 04:06 PM
PhHein
Post your compilable code and the complete stack trace.
• 01-21-2013, 05:33 PM
Aries.
Quote:

Originally Posted by PhHein
Post your compilable code and the complete stack trace.

Im having a problem with the formula or how to derived it( base to exponent ). Le me give you an example like additions.

Quote:

import java.util.Scanner;

public static void main(String[] args) {
Scanner a = new Scanner (System.in) ;
System.out.print("Enter a number: ");
int number1 = a.nextInt();
System.out.print("Enter a number: ");
int number2 = a.nextInt();
int sum = (number1 + number2) ;
System.out.println("The sum of " + number1 + " and " +
number2 + " is " + sum);
}

}
So in the console,
I can type this

Console:
Enter a number: 2
Enter a number: 3
The sum of 2 and 3 is 5

Back to my problem , I;m having a hard time about the exponent thingy, someone says it need loop for re-multiplying the 2nd enter the number to make it as a exponent and the base will multiply depends how many on exponent. :-(
• 01-21-2013, 06:16 PM
foulkelore
Here is link to the JAVA for statement tutorial. Give it a try and let us know if you have any questions. Also in the future you might want to learn how to use the code tags.
• 01-22-2013, 03:44 PM
Aries.
Quote:

Originally Posted by foulkelore
Here is link to the JAVA for statement tutorial. Give it a try and let us know if you have any questions. Also in the future you might want to learn how to use the code tags.

I'm still working on it, but its the same I cant get it. grrr.

• 01-22-2013, 03:55 PM
PhHein
Quote:

Originally Posted by Aries.

Loads of pros. Where is your code? What doesn't work? Where ist the stack trace?
• 01-22-2013, 05:23 PM
JosAH
multiply by 2 (result is 2)
multiply by 2 again (result is 4)
multiply by 2 again (result is 8)

Note that you have multiplied by 2 three times ...

kind regards,

Jos
• 01-23-2013, 04:31 PM
Aries.
Quote:

Originally Posted by JosAH
multiply by 2 (result is 2)
multiply by 2 again (result is 4)
multiply by 2 again (result is 8)

Note that you have multiplied by 2 three times ...

kind regards,

Jos

I tried it already I already loop for the second number to multiply itself from the first number but the answer is too far.
• 01-23-2013, 06:05 PM
JosAH
Quote:

Originally Posted by Aries.
I tried it already I already loop for the second number to multiply itself from the first number but the answer is too far.