elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Mensajes
Páginas: [1]
1  Programación / Java / hacer un programa que cuente cuantos caracteres hay en una palabra(1 sola vez)? en: 26 Febrero 2013, 01:58 am
Bueno tiene que decirme algo asi si es Casa
c 1 vez
a 2 vezs
s 1 vz

llEVO ALGO PERO ME IMPRIME MAS DE UNA VES EL CARACTER ALGUNA IDEA DE QUE HACER
Código:
public static void main(String[] args) {
char com ,
int uno = 0 , contador ;
String texto = "la satania";


while (uno < texto.length()){

com = texto.charAt(uno);
contador =0;

for (int i = 0; i < texto.length(); i++) {
if (com == texto.charAt(i)) {
contador ++;

}

}//fin for

System.out.println(" El caracter " + com + " aparece " + contador + " vecs");

uno++;
}//while
}//main
}//fin Char
xD
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines