I keep getting 1507045888, when i do 2 for base and 2 for exponent.
Here is my code
import java.lang.String;
class values {
int base;
int exponent;
}
class baseExponent {
public static void main(
String args[]) throws java.io.IOException{
values important = new values();
System.out.println("What is the base?");
important.base = (char)System.in.read();
System.in.read();
System.out.println("What is the exponent?");
important.exponent = (char)System.in.read();
System.in.read();
important = math(important);
System.out.println(important.base);
}
public static values math(values Assistance) throws java.io.IOException{
values myAssistance = new values();
int power = Assistance.exponent;
int start = Assistance.base;
int keepValue = 1;
int timekeeper = 1;
if (power == 0) {
System.out.println("The Answer is 1");
} else{
if (power > 0) {
do{
keepValue = keepValue * start;
timekeeper = timekeeper + 1;
}while(timekeeper < power);
} else{
do{
keepValue = keepValue * start;
timekeeper = timekeeper + 1;
}while((timekeeper * -1) > power );
}
if (power < 0) {
keepValue = 1/keepValue;
}
}
myAssistance.base = keepValue;
return myAssistance;
//System.out.println("The answer is " + keepValue);
//System.out.println("What is the base?");
//int base2 = (int)System.in.read();
//System.in.read();
//System.in.read();
//System.out.println("What is the exponent?");
//int exponent2 = (int)System.in.read();
//System.in.read();
//System.in.read();
//math(base2, exponent2);
}
}
Plz help me fix this problem