Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class project {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int rows = 0;
- while (rows < 1 || rows > 9) {
- System.out.println("rows? ");
- rows = sc.nextInt();
- }
- int columns = 0;
- while (columns < 1 || columns > 9) {
- System.out.println(" columns?");
- columns = sc.nextInt();
- System.out.println("side length?");
- System.out.print(" " + "|");
- for (int j = 0; j < columns; j++) {
- System.out.print(" " + j);
- }
- System.out.println();
- for (int j = 0; j <= columns; j++) {
- System.out.print("----");
- }
- System.out.println();
- int[][] board = new int[rows][columns];
- Random rand = new Random();
- for (int i = 0; i < rows; i++) {
- System.out.print(i + " |");
- for (int j = 0; j < columns; j++) {
- board[i][j] = (char) ('*' + Math.random() * ('*'));
- System.out.print(" " + board[i][j]);
- }
- System.out.println();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement