For loops #108 (Press F5 on the browser)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name: A Refresher
/// File Name:ARefresher.java
/// Date Finished: 4/13/2016
import java.util.Scanner;
public class ARefresher
{
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();
if ( name.equals( "Josh" ) )
{
for ( int n = 1 ; n <= 5 ; n = n+1 )
System.out.println( name );
}
else
{
for ( int n = 1 ; n <= 10 ; n = n+1 )
System.out.println( name );
}
System.out.println();
}
}
Picture(s) of the output