how to add character with double so it works like methamatics java -
i have 2 arraylists 1 double name = numbers store user input(double) , sec character name = operators store input(+,-,*,/) entered user. code below. want when user come in values code should numbers value , operation entered in operators. please check code below , tell me how it.
list<double> numbers = new arraylist<>(); list<character> operators = new arraylist<>(); ........................ /* after getting input user code working below.*/ void result() { et1.settext(""); (int = 0; < handler; i++) { double total2 = operators.get(i) + numbers.get(i); total3 += total2; et1.settext(double.tostring(total3)); } } /*all values beingness add together eachother entered user. help me how solve issue. */
basically not possible way doing like:
double total2= operators.get(i)+numbers.get(i);
you need switch operators like:
switch (operators.get(i)) { case '+': //do add together break; case '-': //subtract break blah blah... }
java double character-arrays
No comments:
Post a Comment