I have been writing code for a calculator that will be able to read what the user inputs like a whole arithmetical statement, when i did this i have run into problems. I have been using mainly if statements and while but i would like to know if there is anything in the java library that could make it easier for me to type this code. oh yeah and i would like for it to be able to read the pemdas order of operations. I am using split to separate and isolate what the user inputs and it goes into arrays. then i am using if statements to analyze what the user inputs
.import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public class main {
public static void main(String args[]){
Scanner george = new Scanner(System.in);
String s = george.next();
String[] geor= getIntegers(s);
int[] ints = convertFromString(geor);
String[] operat = getOperators(s);
double answer = ints[0];





for(int x = 0; x<operat.length;x++){
if (operat[x].equals("^")){
if(x ==0){
answer = Math.pow(answer,ints[x+1]);
}
else if(x==operat.length-1){
ints[x]= (int) Math.pow(ints[x],ints[x+1]);
}
else{

}
}
}
for(int x = 0; x<operat.length;x++){
if (operat[x].equals("/")){
if(x ==0){
answer = answer/ints[x+1];
}
}
if (operat[x].equals("*")){
if(x ==0){
answer = answer*ints[x+1];
}
}
}
for(int x = 0; x<operat.length;x++){
if (operat[x].equals("+")){
if(x ==0){
answer = answer+ints[x+1];
}
}
if (operat[x].equals("-")){
if(x ==0){
answer = answer-ints[x+1];
}
}
}
System.out.print(answer);
}






// seperate numbers from other characters




public static String[] getIntegers(String s){
String regex = "[-\\+*/()\\^]";
String[] geo= s.split(regex);
return deletingTheExtraWhiteSpace(geo);

}
public static String[] getOperators(String s){
String regex = "[1234567890.]";
String[] ge= s.split(regex);
return deletingTheExtraWhiteSpace(ge);
}
public static String[] deletingTheExtraWhiteSpace(String[] s){


List<String> list = new ArrayList<String>(Arrays.asList(s));
list.removeAll(Arrays.asList(""));

return list.toArray(EMPTY_STRING_ARRAY);

}
public static int[] convertFromString(String[] s){

if(s != null){
int intarray[]= new int[s.length];
for(int i = 0; i <s.length; i++){
intarray[i] = Integer.parseInt(s[i]);
}
return intarray;
}
return null;

}
private static final String[] EMPTY_STRING_ARRAY = new String[0];

}