Assignemnt #63 and Counting While
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Counting While
/// File Name: CountingWhile.java
/// Date Finished: 11/20/2015
import java.util.Scanner;
public class CountingWhile
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int n = 0, times;
System.out.println("Type in a message, and I'll display it several times.");
System.out.print("Message: ");
String message = keyboard.nextLine();
System.out.print("How many times? ");
times = keyboard.nextInt();
while ( n < times )
{
System.out.println( (n+1)*10 + ". " + message );
n++;
}
//1. removing n++ makes the program go on forever
}
}
Picture of the output