Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

2. How will you handle the situation?

Answered: 1 week ago

Question

Which of the following occurs when you modify a style?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago