double powerTo(double val, int pwr) { if (pwr >= 0) { for (int i = 0; i <= pwr; i++) { val = (val*val); } return val; } else { return 0; } }