SHARE
TWEET

Untitled

a guest Dec 11th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2. import java.util.Random;
  3.  
  4. public class project {
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         int rows = 0;
  8.         while (rows < 1 || rows > 9) {
  9.             System.out.println("rows? ");
  10.             rows = sc.nextInt();
  11.         }
  12.         int columns = 0;
  13.         while (columns < 1 || columns > 9) {
  14.             System.out.println(" columns?");
  15.             columns = sc.nextInt();
  16.             System.out.println("side length?");
  17.             System.out.print("  " + "|");
  18.             for (int j = 0; j < columns; j++) {
  19.                 System.out.print("   " + j);
  20.             }
  21.             System.out.println();
  22.             for (int j = 0; j <= columns; j++) {
  23.                 System.out.print("----");
  24.             }
  25.             System.out.println();
  26.             int[][] board = new int[rows][columns];
  27.             Random rand = new Random();
  28.             for (int i = 0; i < rows; i++) {
  29.                 System.out.print(i + "  |");
  30.                 for (int j = 0; j < columns; j++) {
  31.                     board[i][j] = (char) ('*' + Math.random() * ('*'));
  32.                     System.out.print("   " + board[i][j]);
  33.                 }
  34.                 System.out.println();
  35.  
  36.             }
  37.         }
  38.     }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top