Java project that requests two user numbers, and prints all integers between the first and the second number

Asked

Viewed 384 times

0

int maior ;
System.out.println("digite um numero");
menor = support.TextConsole.getInt();

System.out.println("outro numero");
maior = support.TextConsole.getInt();
do{
    menor = maior;
    menor++;
    System.out.println(menor);
} while(menor > maior);

1 answer

0

Your algorithm is very weak from what I’ve seen,

it’s been a long time since I programmed in java, I made a code here very fast and without testing obviously, but I believe it solves your problem.

Focus on your algorithm.

import java.util.Scanner;
public class MyClass {
    public static void main(String args[]) {
        Scanner ler = new Scanner(System.in);
        int maior;
        int menor;


        System.out.println("digite um numero");
        menor = ler.nextInt();

        System.out.println("outro numero");
        maior = ler.nextInt();

        do{
            menor++;
            System.out.println(menor);
        } while(menor < maior);

    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.