Assignemnt #74 Counting With 4 Loop
Code
/// Name: JJ Deng
/// Period: 6
/// Program Name: Counting With For Loop
/// File Name: CountingWith4Loop.java
/// Date Finished: 1/17/2016
import java.util.Scanner;
public class CountWith4Loop
{
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 )//the program wont stop if u remove n= n+1
{ //the program won't run without int n= 1
System.out.println( n + ". " + message );
}
}
}
Picture of the output