You are on page 1of 1

5 )

Scanner leer=new Scanner(System.in);


System.out.println("Ingrese el nmero, porfavor ");
int a ,b,c,num;
int n =leer.nextInt();
a=Math.floorDiv(n, 1000);
n=n-a*1000;
b=Math.floorDiv(n, 100);
n=n-b*100;
c=Math.floorDiv(n, 10);
n=n-c*10;
num=a+b*10+c*100+n*1000;
System.out.println("El nuevo numero es :"+num);
}
}
4 )
Scanner leer=new Scanner(System.in);
System.out.println("Ingrese el nmero, porfavor ");
int a ,b,c,sum;
int n =leer.nextInt();
a=Math.floorDiv(n, 1000);
n=n-a*1000;
b=Math.floorDiv(n, 100);
n=n-b*100;
c=Math.floorDiv(n, 10);
n=n-c*10;
sum=a+b+c+n;
System.out.println(a+" + "+ b+ " + "+c+" + "+n+" = "+sum);
}
}

You might also like