Assignment #78 and Counting With A While Loop
Code
/// Name: Tim Chuang
/// Period: 7
/// Program Name: Counting With A While Loop
/// File Name: CountingWithAWhileLoop.java
/// Date Finished: 3/4/2016
import java.util.Scanner;
public class CountingWithAWhileLoop
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System. out.println( " Type in the gud one and I'll display it ten times." );
System.out.print( " Gud one: ");
String message = keyboard.nextLine();
for ( int n = 1 ; n <=10 ; n = n+1 )
{
System.out.println( n + ". " + message );
}
}
}
// n+1 makes it add another
// n = 1 sets the variable
Picture of the output