Assignment #63 and Counting While
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Counting While
///File Name: CountingWhile.java
///Date Finished: 10/19/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 however many times you ask." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print( "How many times? " );
int x = keyboard.nextInt();
int n = 0;
while ( n < x )
{
System.out.println( ((n+1) * 10 ) + ". " + message );
n++;
}
}
}
//1. n++ adds 1 to n so that it will eventually reach 5, if you remove it, the while loop just keeps repeating
Picture of the output