Assignment 63; CountingWhile
Code
// Donovan Rich
// Period 6
// Counting with a while loop
// CountingWhile.java
// 12/8/2015
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 five times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print( "Repeats?: " );
int rep = keyboard.nextInt();
int n = 0;
while ( n < rep*10 )
{
System.out.println( (n+10) + ". " + message );
n+=10;
}
}
}
Picture of the output