Assignment #78
Code
/// Name: Ian Stanko
/// Period: 5
/// Program Name: counting
/// File Name: counting.java
/// Date Finished: 1/27/2016
import java.util.Scanner;
public class counting
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println( "Type in a message, and I'll display it five times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
for ( int n = 2 ; n <= 20; n = n + 2 )
{
System.out.println( n + ". " + message );
}
}
}
// if you remove the n= n+1 the program will go on forever. It adds 1 to n, and when it hits five, its stops.
// if you remvoe the in n=1 then there is nothing to initialize the n
Picture of the output HOME