Computer Science, asked by selviravi059, 7 months ago

create a new class called calculator with following methods 1. A static method called power Int( int num1, int num2).this method should return to the power num 2.
2. A static method called power double(double num1, intnum2)
this method should return num1 to the power num2
3.invoke both the method and test the functionalities

Answers

Answered by msjayasuriya4
1

Answer:

Create a new class called “Calculator” which contains the following: 1. A static method called powerInt(int num1,int num2) that accepts two integers and returns num1 to the power of num2 (num1 power num2). 2. A static method called powerDouble(double num1,int num2) that accepts one double and one integer and returns num1 to the power of num2 (num1 power num2). 3. Call your method from another class without instantiating the class (i.e. call it like Calculator.powerInt(12,10) since your methods are defined to be static) Hint: Use Math.pow(double,double) to calculate the power.

Code>>>

public class CALCI {

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println(Calculator.powerDouble(85.0, 2));

System.out.println(Calculator.powerInt(85,3));

}

}

class Calculator

{

static double powerInt(int num1,int num2)

{

return Math.pow(num1,num2);

}

static double powerDouble(double num1,int num2)

{

return Math.pow(num1,num2);

}

}

Posted 5th July 2018 by Anonymous

Labels: class and object

Answered by ishu8424
0

Answer:

yes upper answer is right

Similar questions