Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boolean sprawdzPoprawnosc(String lancuch){
- boolean wynik = false;
- int operatory = 0;
- int zmienne = 0;
- for(int i = 0; i < lancuch.length(); i++){
- if(lancuch.charAt(i) == '+' || lancuch.charAt(i) == '-' || lancuch.charAt(i) == '*' || lancuch.charAt(i) == '/') operatory++;
- if(Character.isLetter(lancuch.charAt(i))) zmienne++;
- }
- if((operatory+1)==zmienne) wynik = true;
- else wynik = false;
- System.out.println("operatory: "+operatory + ", zmienne:" + zmienne);
- return wynik;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement