Assignment #78 Counting with a For Loop
Code
///Name: Ian Grant
///Period:5
///Project Name: Counting with a For Loop
///File Name:CountFor.java
///12/10/15
import java.util.Scanner;
public class CountFor
{
public static void main(String[] args)
{
//1. It stops it from infinatly looping
//2. intiates n to 1
Scanner stuff=new Scanner(System.in);
System.out.println("Type a message and I'll display it five times.");
System.out.print("Message: ");
String message = stuff.nextLine();
for (int n=2; n<=10;n=n+2)
{
System.out.println(n+". "+message);
}
}
}
Output