Assignment #63
Code
/// Name: Ian Stanko
/// Period: 5
/// Program Name: CountingWhileloops
/// File Name: CountingWhileloops.java
/// Date Finished: 1/5/2016
import java.util.Scanner;
public class CountingWhileloops
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int n=0, number;
System.out.println( "Type in a message, and I'll display it ten times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print( "How many times? " );
number = keyboard.nextInt();
while ( n < number )
{
System.out.println( (n+1)*10 + ". " + message );
n++;
}
}
}
//removing the 'n++" makes the program go on forever
Picture of the output