Assignement: #78 Counting using a For Loop
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: CountingFor
/// File Name: CountingFor.java
/// Date Finished: 12/16/2016
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 five times. " );
System.out.print( "Message: " );
String message = keyboard.nextLine();
for ( int n = 2 ; n <= 10 ; n = n+2 )
{
System.out.println( n + " . " + message );
}
}
}
///n = n+1 is the amount you are adding to the variable, giving it a new value.
/// It creates the variable, deleting it will cause the program to be unoperable.
Picture of the output