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