[Java Eclipse] About this problem

Sample output :

Enter first number : 2

Enter second number : 3

Answer is : 8

// 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.

Re: [Java Eclipse] About this problem

Post your compilable code and the complete stack trace.

Re: [Java Eclipse] About this problem

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 class Addition {

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

Re: [Java Eclipse] About this problem

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.

Re: [Java Eclipse] About this problem

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.

thanks for the reply,

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

Any pro there please?

Re: [Java Eclipse] About this problem

Quote:

Originally Posted by

**Aries.** Any pro there please?

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

Re: [Java Eclipse] About this problem

Start with a number 1;

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

Re: [Java Eclipse] About this problem

Quote:

Originally Posted by

**JosAH** Start with a number 1;

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.

Re: [Java Eclipse] About this problem

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.

Conclusion: your code isn't corrrect.

kind regards,

Jos

Re: [Java Eclipse] About this problem

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