Here is the code the 6th period class wrote:
import java.util.Scanner; /** * Write a description of class Demo here. * * @author (your name) * @version (a version number or a date) */ public class Demo { // instance variables - replace the example below with your own private int x; /** * Constructor for objects of class Demo */ public Demo() { // Rectangle with Hole Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int y = scan.nextInt(); //y = y*2; for(int j = 0; j < y; j++){ if (j == 0){ //Top for(int i = 0; i < x; i++){ System.out.print("X"); } } else if(j == ( y - 1 )){ // Bottom for(int i = 0; i < x; i++){ System.out.print("X"); } } else{ // Middle System.out.print("X"); for(int i = 1; i < (x-1); i++){ System.out.print(" "); } System.out.print("X"); } System.out.println(""); } } //Double Y Height Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int y = scan.nextInt(); while(j < 2*y){ for(int i = 0; i < x; i++){ System.out.print("X"); } j++; System.out.println(""); } // Full Rectangle Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int y = scan.nextInt(); while(j < y){ for(int i = 0; i < x; i++){ System.out.print("X"); } j++; System.out.println(""); } // Fix #2 Scanner scan = new Scanner(System.in); int x = scan.nextInt(); for(int i = 1; i <= x; i++){ System.out.print("X"); } // Fix #1 Scanner scan = new Scanner(System.in); int x = scan.nextInt(); for(int i = 0; i < x; i++){ System.out.print("X"); } // Off by 1 Scanner scan = new Scanner(System.in); int x = scan.nextInt(); for(int i = 0; i <= x; i++){ System.out.print("X"); } }