Assignment #78
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Counting with a For Loop
/// File Name: CountingFL.java
/// Date Finished: 500 BCE
import java.util.Scanner;
public class CountingFL
{
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 );
}
/// The n = n+1 tells the computer how many times the message has been displayed by adding 1 to n every time it is shown.
/// The n = 1 tells the computer what to print n as.It also defines how many times the message has been shown.
}
}
Code Output