Assignemnt #78 and Counting with a For Loop
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: SafeSquareRoot
/// File Name: SafeSquareRoot.java
/// Date Finished: 1/5/2016
import java.util.Scanner;
public class CountingForLoop {
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 <= 11 ; n = n+2 )
{
System.out.println( n + ". " + message );
}
}
}
/*
1. (n = n + 1) makes the next loop n, one digit higher. n will only repeat the no. of times sent.
2. It initially put n as 1.
*/
prog78.PNG