Assignment #78 Counting For Loops
Code
/// Name: Lacey Reese
/// Period: 5
/// Program Name: CountingForLoops
/// File Name: CountingForLoops.java
/// Date Finished 2/3/2016
import java.util.Scanner;
public class CountingForLoops
{
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+1 )
{
System.out.println( n + ". " + message );
}
/// The n = n+1 says how many times the message will be displayed by adding 1 to n.
/// The n = 1 tells what to print n as. It also says how many times the message has been printed.
}
}
Picture of the output
//