1
I need the program to remove a value from the user’s number until it reaches 0. I don’t know if the loop used should be the for, but my program was like this.
package numerodescrecente;
import java.util.Scanner;
public class NumeroDescrecente {
public static void main(String[] args) {
Scanner leitor = new Scanner(System.in);
System.out.println("DIGITE UM NUMERO");
int n1 = leitor.nextInt();
for (n1=n1;n1>0;n1--)
{
System.out.println("Numero: "+n1);
}
}
}
If you wish to include the
0
, you must change the conditionn1>0
forn1>=0
– Leonardo Santos