Assignment #63

Code

    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: ThreeCardMonte
    ///File Name: ThreeCardMonte.java
    ///Date: 11/13/15
    
    import java.util.Scanner;

    public class CountingWhile
    {
    	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 so that it will repeat 5 times. If you remove n++ it will infinitely repeat.
    2. changed line 14 to ( n < 10 )
    3. changed n+1 to (n+1)*10
    */


        
    

Picture of the output

Assignment 63 Assignment 63