Assignemnt #78 and Counting For
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Counting For
///File Name: CountingFor
///Date Finished: 2/2/16
import java.util.Scanner;
public class CountingFor
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println( "Type in a message, and I'll display it ten times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
//The "n = n+1 makes "n" be redefined each time the loop is done.
//The "int n = 1" defines "n" as 1.
for ( int n = 2 ; n <= 10 ; n = n+2 )
{
System.out.println( n + ". " + message );
}
}
}
Picture of the output