Assignemnt #63 and Counting with a While Loop
Code
///Name: Ben Borglin
///Period: 6
///Program name: Counting While
///file name: CountingWhile.java
///Date Finsihed: 10/21/15
import java.util.Scanner;
public class CountingWhile
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println( "Type in a message, and I'll display it." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print("How many times does you want it to print?");
int stop = keyboard.nextInt();
int n = 0;
while ( n < stop )
{
System.out.println( (n+10) + ". " + message );
n = n + 10;
}
}
}
///the n++ adds one to the variable 'n'
Picture of the output