Professional Documents
Culture Documents
Java Demo - 039
Java Demo - 039
double b;
int e;
double val;
Pwr(double base, int exp) {
b = base;
// this.b = base;
e = exp;
// this.e = exp;
val = 1;
// this.val = 1;
if(exp==0) return;
for( ; exp>0; exp--) val = val * base;
// for( ; exp>0; exp--) this.val = this.val * base;
}
/*
Pwr(double b, int e) {
this.b = b;
this.e = e;
val = 1;
if(e==0) return;
for( ; e>0; e--) val = val * b;
}
*/
double get_pwr() {
return val;
// return this.val;
}
}
class DemoPwr {
public static
Pwr x
Pwr y
Pwr z