Assignemnt #63 and Counting While
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Counting While
///File Name: CountingWhile
///Date Finished: 12/1/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 five times." );
System.out.print( "Message: " );
String message = keyboard.nextLine();
System.out.print( "How many times?: " );
int times = keyboard.nextInt();
int n = 0;
while ( n < times )
{
System.out.println( ((n+1)*10) + ". " + message );
n++;
//The n++ tells the program to continue the program, not having it just repeat the same message over and over.
}
}
}
Picture of the output