Advertisement
RAUL-SUAREZ

Untitled

Aug 19th, 2020
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class punto3 {
  4.     public static void main(String[] args) {
  5.         // TODO Auto-generated method stub
  6.         Scanner num= new Scanner (System.in);
  7.        
  8.         int x,cont=0;
  9.         double prom, suma=0;
  10.         System.out.println("Ingrese un numero positivo");
  11.        
  12.         x=num.nextInt();
  13.         if(x>0) {
  14.             System.out.println("sus numeros divisores son");
  15.             for (int i=1;i<=x;i++) {
  16.                         if(x%i==0) {
  17.                         System.out.println(i);
  18.                         suma+=i;
  19.                         cont++;
  20.                     }
  21.                 }
  22.             System.out.println("son "+cont+" divisores");
  23.             prom=(suma/cont);
  24.             System.out.println("su promedio es "+prom);
  25.             }
  26.         else {
  27.             System.out.println("no es valido el numero ingresado");
  28.         }
  29.        
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement