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*; import java.util.*; i public class SumaDigitos{ p public static Scanner teclado = new Scanner(; 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online