SumaDigitos

SumaDigitos - p int n do System.out.print"Ingrese el...

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 dígitos es: "+suma(n)); " }while(n!=0); } System.out.println("\n « fin de la aplicación »"); S } }...
View Full Document

This note was uploaded on 10/29/2009 for the course ITC TC-1002 taught by Professor X during the Spring '09 term at ITESM.

Ask a homework question - tutors are online