Computer Science (Java)

Write a program that displays a window into a “network” of boxes connected by lines. See examples below. Query the user for the width and height of the display window (in characters) and also the size of the boxes (they are squares of with identical height and width, in characters) and the length of an edge (lines between boxes, in characters). Draw the network of boxes starting from the upper left, starting always with a square. Connect squares horizontally and vertically with an edge in the middle of the box. Any inputs that are not positive integers should be queried again until the user provides a positive integer.

If the square size is even, edges should be double width. If the square size is odd, use only single “-” characters. Square corners should be rendered with a “#” character. The pipe character (“|”) can be found on your keyboard above the backslash character.

Your program should work with any positive value for the size of the squares, the length of the edges, and the height and width of the display window.

The input on the screen might look like this (two lines when square size is even):

Input your desired height: derp!
Error: please type in an integer.
Input your desired height: 21
Input your desired width: 39
Input square size: 8
Input edge length: 4
#------# #------# #------# #--
| | | | | | |
| | | | | | |
| |----| |----| |----|
| |----| |----| |----|
| | | | | | |
| | | | | | |
#------# #------# #------# #--
|| || ||
|| || ||
|| || ||
|| || ||
#------# #------# #------# #--
| | | | | | |
| | | | | | |
| |----| |----| |----|
| |----| |----| |----|
| | | | | | |
| | | | | | |
#------# #------# #------# #--
|| || ||

Or look like this (Here the square (size 1) is just a single “#”. The connection between the squares is the - character. Odd-sized squares just have one line, not two):

Input your desired height: 11
Input your desired width: 26
Input square size: 1
Input edge length: 3
#---#---#---#---#---#---#-
| | | | | | |
| | | | | | |
| | | | | | |
#---#---#---#---#---#---#-
| | | | | | |
| | | | | | |
| | | | | | |
#---#---#---#---#---#---#-
| | | | | | |
| | | | | | |

Or look like this (the window is smaller than a single square):

Input your desired height: 8
Input your desired width: 14
Input square size: 26
Input edge length: 25
#-------------
|
|
|
|
|
|
|

  1. 👍 0
  2. 👎 0
  3. 👁 50

Respond to this Question

First Name

Your Response

Similar Questions

  1. TI-83 CALC PROGRAM

    Please can anyone help me with this or any part of it? Be very grateful as left it too late... Write a program for ti-83 calculator which generates and displays integer values for A, B and C between 1 and 10; • requests the

    asked by Jo on June 14, 2010
  2. Programming using C#

    Write a program that displays your initials in a pattern on the screen. Compose each initial with six lines of smaller initials, as the following example: J FFFFFF J F J FFF J F J J F JJJJJJ F

    asked by Mike on September 28, 2011
  3. C#

    Write a program that displays your initials in a pattern on the screen. Compose each initial with six lines of smaller initials, as the following example: J FFFFFF J F J FFF J F J J F JJJJJJ F

    asked by Mike on September 29, 2011
  4. maths HELPPP

    Y= AX + B Write a program for the calculator which: • Generates and displays suitable integer values of A and B: • Requests the student to input the coefficient of Y and the constant term in the re arranged formula; • Checks

    asked by kat on June 7, 2007
  5. Programming and Design

    Draw the hierarchy chart and design the logic for a program that calculates the projected cost of an automobile trip. Assume that the user's car travels 20 miles per gallon of gas. Design a program that prompts the user for a

    asked by Matt on April 3, 2013
  6. Programming Java

    I am learning Java in programming right now. I need to write a program that should have an output like this: The program says "Type ten names". Then ten names sould be typed a person. Then the program chooses a random name from

    asked by Valerie on November 16, 2017
  7. Java

    Write a GUI application that prompts the user for a number between 1 and 5. Be sure to include error checking so that the program continues to prompt the user for a number until the user's entry is between 1 and 5, inclusive. Once

    asked by Robert on December 15, 2009
  8. Science

    These are the instructions on a homework worksheet: "Measure the following lines using a ruler and write the measurements in the boxes provided." "Measuring Lines in cm - exact" Can someone please tell me what they mean by

    asked by Smom on August 27, 2011
  9. programming

    write a c program that accepts a name as first name last name but displays the name as last name first name in the output

    asked by amy on July 16, 2011
  10. computers

    On an Ethernet 10BaseT network, all computers are connected with a hub. Recently a network-intensive application had been installed, and users are complaining that response times are quite slow on the network. You decide that you

    asked by TaKayla on March 19, 2010

More Similar Questions