John B.

asked • 03/12/20

Cannot figure how to output numbers horizontally in Java

This is my code, it is suppose to output 10 numbers per line but it only works with the #7. I am ask to make the code user input-able, which that part is done.


import java.util.Scanner;
public class CountByAnything
{
// Modify the code below
public static void main (String args[])
{
Scanner input = new Scanner(System.in);
System.out.println("Enter a value");
int alpha = input.nextInt();
int START = alpha;
final int STOP = 500;
final int NUMBER_PER_LINE = 10;
for(START = alpha; START <= STOP; START += alpha)
{
System.out.print(START + " ");
if(START % NUMBER_PER_LINE == alpha)
System.out.println();

}
}
}


1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.