Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Hector Villalobos
- //PROGRAMMING I M-F 11am
- import java.util.Scanner;
- import java.io.*;
- public class Challenge20SquareDisplayOutput {
- public static void main(String[] args) throws IOException {
- Scanner keyboard = new Scanner(System.in);
- PrintWriter outputFile = new PrintWriter("SquareDisplay.txt");
- System.out.print("Enter a positive integer no greater than 15: ");
- int input = keyboard.nextInt();
- while(input > 15) {
- System.out.print("Invalid integer. Try Again: ");
- input = keyboard.nextInt();
- }
- for(int i = 1; i <= input; i++) {
- for(int j = 1; j <= input; j++)
- outputFile.print("X");
- outputFile.println();
- }
- outputFile.close();
- System.out.println("Data written to the file.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement