Assignemnt #78 and Counting with a for loop
Code
///name: nick cerdan
///period: 6
///program name: Counting with a for loop
///file name: CountingFor.java
///date finished: 10/29/15
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 = 1 ; n <= 10 ; n = n+1 )
{
System.out.println( (n*2) + ". " + message );
}
}
}
///removing the 'n = n + 1' makes n stay at 1 forever, so the the loop never terminates
///the 'int n = 1' declares and initializes the varibale n