What I'm looking to do is a counter that adds the value of each word in its ASCI code. For example: Hello (H = 45, or = 56, l = -45, a = 23. Total Value = 79).
This is the code of my Accountant:
public class Accountant {
public static final char espacio = ' ';
char[] pal; //Definim l'array paraula
Paraula p = new Paraula();
public int ContarPes() {
String S; //Creamos el String para leer desde teclado
S = new LT().llegirLinia(); //Leemos todo el string
pal = S.toCharArray(); //Pasamos el String S a Array
int PesPal = 0; //Ponemos el contador a 0 , el cual dice qué pesa cada palabra
for (int i = 0; i < pal.length; i++) {
PesPal = PesPal + pal[i];
}
return PesPal;
}
}
My problem lies in knowing when you have already read a word, how can you move on to the next one. And at the end I printed the sum of each word per screen.
EDIT: I can only use the String for input or output.