1. Member
Join Date
Jan 2013
Posts
22
Rep Power
0

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.

Post your compilable code and the complete stack trace.

3. Member
Join Date
Jan 2013
Posts
22
Rep Power
0

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.

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. :-(

4. Member
Join Date
Dec 2012
Location
Des Moines, IA
Posts
35
Rep Power
0

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.

5. Member
Join Date
Jan 2013
Posts
22
Rep Power
0

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.

Originally Posted by Aries.
Loads of pros. Where is your code? What doesn't work? Where ist the stack trace?

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

8. Member
Join Date
Jan 2013
Posts
22
Rep Power
0

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.

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.

kind regards,

Jos

10. Moderator
Join Date
Apr 2009
Posts
13,222
Rep Power
23

...and without seeing the code (including your output and any debugging you have done) we can't say why it is wrong.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•