kimikom

Untitled

Dec 11th, 2019
135
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. int length = 0;
  17. System.out.println("side length?");
  18. length = sc.nextInt();
  19. System.out.print(" " + "|");
  20. for (int j = 0; j < columns; j++) {
  21. System.out.print(" " + j);
  22. }
  23. System.out.println();
  24. for (int j = 0; j <= columns; j++) {
  25. System.out.print("----");
  26. }
  27. System.out.println();
  28. int[][] board = new int[rows][columns];
  29. Random rand = new Random();
  30. for (int i = 0; i < rows; i++) {
  31. System.out.print(i + " |");
  32. for (int j = 0; j < columns; j++) {
  33. board[i][j] = (char) ('*' + Math.random() * ('*'));
  34. System.out.print(" " + board[i][j]);
  35. }
  36. System.out.println();
  37.  
  38. }
  39. }
  40. }
  41. }
RAW Paste Data