So I have to make a code that asks the user how many times it wants the word "nonsense" to be printed on a new line, I managed to get it to work but its reverse, if i write 100 it prints once and 1 it prints hundred times, how can i solve it so it make the user input tell the programme how many times it should print out the line.
my code is:
import java.util.Scanner;
public class fix {
public static void main(String[] args) {
Scanner scan = new Scanner (System.in);
int antal = 0;
int i = 1;
System.out.println("Enter how many times we should print out the word nonsense");
antal = scan.nextInt();
while (100 > antal)
{
System.out.print(" \nnonsense");
antal += i;
}
}
}