# [Java Eclipse] About this problem

Printable View

• 01-18-2013, 03:49 PM
Aries.
[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.
• 01-18-2013, 04:06 PM
PhHein
Re: [Java Eclipse] About this problem
Post your compilable code and the complete stack trace.
• 01-21-2013, 05:33 PM
Aries.
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. :-(
• 01-21-2013, 06:16 PM
foulkelore
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.
• 01-22-2013, 03:44 PM
Aries.
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?
• 01-22-2013, 03:55 PM
PhHein
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?
• 01-22-2013, 05:23 PM
JosAH
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
• 01-23-2013, 04:31 PM
Aries.
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.
• 01-23-2013, 06:05 PM
JosAH
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
• 01-23-2013, 06:35 PM
Tolls
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.