SumaDigitos

SumaDigitos - p int n; do{...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.io.*; import java.util.*; i public class SumaDigitos{ p public static Scanner teclado = new Scanner(System.in); p public static int suma(int n){ int acum = 0; while(n>=1){ acum = n%10 + acum; n = n/10;} return acum;} r public static void main(String args[]){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: p int n; do{ System.out.print("Ingrese el valor de n (mayor que 0): "); n = teclado.nextInt(); n System.out.println("\nLa suma de los dgitos es: "+suma(n)); " }while(n!=0); } System.out.println("\n fin de la aplicacin "); S } }...
View Full Document

Ask a homework question - tutors are online