Assignement: Using For loops with only one If Statement
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: RefresherChallenge
/// File Name: RefresherChallenge.java
/// Date Finished: 4/23/2016
import java.util.Scanner;
public class RefresherChallenge
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String name;
System.out.print( "Your name: " );
name = keyboard.next();
System.out.println();
if ( name.equals("Josh"))
{
for ( int x = 0; x <= 5; x++)
{
System.out.println( "Josh" );
}
}
while ( !name.equals("Josh"))
{
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
System.out.println(name);
name = "Josh";
}
}
}
Picture of the output