Assignemnt #63 and Counting with a While Loop
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: CountingWithLoop
/// File Name: CountingWithLoop.java
/// Date Finished: 1/5/2016
import java.util.Scanner;
public class CountingWithLoop {
public static void main( String[] args ) {
Scanner keyboard = new Scanner(System.in);
int 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();
int n = 0;
while ( n != times )
{
System.out.println( ((n+1)*10) + ". " + message );
n++;
}
}
}
/*
1. n++ adds one repeat, so it will repeat 5 times. If you remove it it will infinitely repeat.
2. ok
3. ok
*/
prog63.PNG