Assignment #63
Code
/// Name: Mahima Choudhary
/// Period: 6
/// Program Name: Counting with a While Loop
/// File Name: CountingWhile.java
/// Date Finished: 12/9/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 several times.");
System.out.print("Message: ");
String message = keyboard.nextLine();
System.out.print("How many times? ");
int repeat = keyboard.nextInt();
int n = 0;
while ( n < repeat )
{
System.out.println( ((n+1)*10) + ". " + message );
n++;
}
}
}
//n++ allows for +1 to n variable for every time the loop is run
Picture of the output