For loops #109 (Not much of a challenge though...)

Code

/// Name: Amir Salehi
/// Period: 7
/// Program Name: Refresher Challange
/// File Name:RefresherChallange.java
/// Date Finished: 4/20/2016

    
    import java.util.Scanner;
    
    public class RefresherChallenge
    {
        public static void main( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            
            System.out.println();
            System.out.print( "What is your name? " );
            String name = keyboard.next();
            
            System.out.println();
            
            int x = 10;
            
            if ( name.equals( "Josh" ) )
            {
                x = x - 5;
            }
            
            for ( int n = 1 ; n <= x ; n = n+1 )
                System.out.println( name );
    
            System.out.println();
        }
    }  






    

Picture(s) of the output

Assignment 7

Back to Homepage