mercredi 29 novembre 2017

charAt not working in java fraction calculator

This code returns false even when input has an underscore. Input would be something like 1_3/4 + 3 and would return 4_3/4

  String[] Separated = fraction.split(" "); //Splits the tokens up
  String firstToken = Separated[0]; // I created this to try to troubleshoot
  boolean Mixed = true; //This would determine how much I will need to split up
  for(int i = 0; i < firstToken.length(); i++) {
     if(firstToken.charAt(i) == '_') { 
        Mixed = true;
     }
     else {
        Mixed = false;
     }
  }

Aucun commentaire:

Enregistrer un commentaire