Assignemnt #81 Counting Machine Revisited
Code
Name: Iaroslav Titov
Period: 7
Project Name: CountMachine2
File Name: CountMachine2.java
Date: 1/11/2015
import java.util.Scanner;
public class CountMachine2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.print( "Count from: " );
int countFrom = keyboard.nextInt();
System.out.print( "Count to: " );
int countTo = keyboard.nextInt();
System.out.print( "Count by: " );
int countBy = keyboard.nextInt();
for(int i = 0; i <= countTo/countBy - countFrom/countBy; i++)
{
System.out.print(((countFrom + countBy*i) < 10?" ":"") + (countFrom + countBy*i) + " ");
if(i % 10 == 0 && i != 0) {
System.out.print("\n");
}
}
System.out.print("\n ");
}
}
Picture of the output