/*
Write a java program which will
accept base number and exponent
number from command line argument
and find the value of base to
the power of exponent
The exponent value may be negative
value.
*/
class p411b
{
public static double power(double b,double p)
{
double i,v;
v=1;
for(i=1;i<=Math.abs(p);i++)
v=v*b;
if(p<0)
v=1/v;
return v;
}
public static void main(String args[])
{
double b,p;
b=Double.parseDouble(args[0]);
p=Double.parseDouble(args[1]);
System.out.println("Result = " + power(b,p) );
}
}
Write a java program which will
accept base number and exponent
number from command line argument
and find the value of base to
the power of exponent
The exponent value may be negative
value.
*/
class p411b
{
public static double power(double b,double p)
{
double i,v;
v=1;
for(i=1;i<=Math.abs(p);i++)
v=v*b;
if(p<0)
v=1/v;
return v;
}
public static void main(String args[])
{
double b,p;
b=Double.parseDouble(args[0]);
p=Double.parseDouble(args[1]);
System.out.println("Result = " + power(b,p) );
}
}
No comments:
Post a Comment