Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pide el ingreso de un numero mayor que el 25 pero menor que el 99.
- // Y que el programa imprima ese numero, y al lado, el producto de sus
- // digitos, consecutivamente hasta que el producto sea de un solo digito.
- // Que repita el proceso en cada linea con el numero ingresado +1 hasta
- // llegar al 99. (El programa no imprime cuando el producto es 0).
- import java.util.Scanner;
- public class siguiente01{
- public static void main (String args[]){
- int N = leaNumero();
- imprimeSecuencias(N);
- }
- public static void imprimeSecuencias(int ini){
- int in = 0;
- int dec = 0;
- int uni = 0;
- for (int i = ini; i<100;i++){
- in = i;
- while (in>=10){
- System.out.print(in+" ");
- dec = (in/10);
- uni = (in - (dec*10));
- in = (uni*dec);
- }if (in!=0){
- System.out.print(in);
- }System.out.println();
- }
- }
- public static int leaNumero(){
- Scanner tec = new Scanner(System.in);
- int X = 0;
- boolean error = false;
- do{
- if (error){
- System.out.println("Error! Numero ingresado no estra dentro del rango (26~98).");
- }System.out.print("Ingrese un numero (26~98): ");
- X = tec.nextInt();
- error = true;
- }while(X>=99||X<=25);
- return X;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement