Assignment 81

Code

    import java.util.Scanner;
    
    public class CountingMachine2
    {
        public static void main( String[] args )
        {
            Scanner bot = new Scanner(System.in);
            
            
            System.out.println("Count from: ");
            int from = bot.nextInt();
            System.out.println();
            
            System.out.println("Count to: ");
            int to = bot.nextInt();
            System.out.println();
            
            System.out.println("Count by: ");
            int by = bot.nextInt();
            System.out.println();
            
            for ( int n = from; n <= to; n = n + by )
            {
                System.out.print( " " + n );
            }
            
            System.out.println();
            
            
        }
    }      
    

Picture of the output

Assignment