Jake here, im new to this forum, im also new to java and recently got a bit stuck in a programming exercise for my module. I know it'll probably be really easy to some people but i thought id share it because im still only learning.The question is as follows:
Write a class method which calculates the power of one number raised to another. The method would be used as follows:
Use this method to print the first 20 powers of 2.int x = getPower(2, 5); // 2 to the power of 5 = 32 int x = getPower(3, 4); // 3 to the power of 4 = 81
The class method i will use will be something like this:
static int getPower(int num, int power){ }
Im basically just confused about how i would go about doing this and whether or not i need to use a for loop. Any help would be greatly appreciated.
Thanks and il look forward to talking with you all throughout the forum