Question
I need help writing this program in JAVA, this is an introductory java course, so if possible, keep it as basic/simple as possible while still
I need help writing this program in JAVA, this is an introductory java course, so if possible, keep it as basic/simple as possible while still following the instructions. The output should look like the sample execution at the end of the problem.
Write a program which asks the user to enter the size of a grid and display the corresponding grid. The dimensions of the grid will be the same in each dimension, so if the user enters 4, you would display a 4 x 4 grid. If the user enters 10, you would display a 10 x 10 grid, and so on. See below for examples.
Input Validation:
The size of the grid must be a positive integer.
Requirements:
You must design your program to use methods correctly.
You must design your program to theoretically work for any input value.
Hints:
You might want to have a method that takes the grid size and prints one line of the grid that has the plus signs: +--+--+--+--+--+
You might want to have a method that takes the grid size and prints one line of the grid that has the vertical pipes: | | | | | |
You might want to have a method that takes the grid size and using the previous two methods, display the correct result.
Choose your return types wisely.
Sample Execution 1:
Enter the size of the grid: 1 +--+ | | +--+
Sample Execution 2:
Enter the size of the grid: 5 +--+--+--+--+--+ | | | | | | +--+--+--+--+--+ | | | | | | +--+--+--+--+--+ | | | | | | +--+--+--+--+--+ | | | | | | +--+--+--+--+--+ | | | | | | +--+--+--+--+--+
Sample Execution 3:
Enter the size of the grid: 10 +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+ | | | | | | | | | | | +--+--+--+--+--+--+--+--+--+--+
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started