Assignemnt #76 Counting Machine 2
Code
/// Name: JJ Deng
/// Period: 6
/// Program Name: Counting Machine Revisited
/// File Name: CountingMachine2.java
/// Date Finished: 1/27/2016
import java.util.Scanner;
public class CountingMachine2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int to, by, from;
System.out.print("Count from: ");
from = keyboard.nextInt();
System.out.print("Count to: ");
to = keyboard.nextInt();
System.out.print("Count by: ");
by = keyboard.nextInt();
System.out.println();
for (int n= from; n <= to; n= n + by)
{
System.out.print(n + " " );
}
}
}
Picture of the output