import java.util.Scanner; public class Multiples { public static void main (String [] args) { final int PER_LINE = 5; int value, limit, mult, count = 0; Scanner scan = new Scanner ( System.in); System.out.print(" Enter a positive value: " ); value = scan.nextInt(); System.out.print( " Enter an upper limit: " ); limit = scan.nextInt(); System.out.println (); System.out.println(" The multiples of " + value + " between " + value + " and " + limit + " ( inclusive ) are: " ); for ( mult = value; mult <= limit; mult += value) { System.out.println( mult + "\t" ); count++; if ( count % PER_LINE ==0 ) System.out.print(); } } }
So I'm just really confused about how the for loop works in this program, my book says " the increment portion of the for loop in the multiples program adds the value entered by the user after each iteration. The number of values printed per line is controlled by counting the values printed and then moving to the next line when ever count is evenly divisible by the PER_LINE constant. "
so in the initiation part of the for loop, mult = value, so if the value entered in was 7, with limit being entered in at 400, then mult = 7, in which case by " mult += value", it would be 14 right? if this is true, how does the program keep adding on values to where the output produces multiples of 7?? Sorry i'm just really lost here lol