In this assignment, you will write a program that prints out a text-art castle (not as cool as the one pictured below, though).
”
The size of the castle will be controlled via three input numbers. You do not need to do any error-checking on these numbers. From these three numbers, you will generate a castle that can vary in height and size, according the input numbers.
The three numbers that you will read in from the user are as follows:
Tower height: ?
Tower separation: ?
Main castle height: ?
Each of these number will control various aspects of the printed output, which will look like a castle.
You should use a combination of string multiplication and while-loops to implement this program.
The tower height will control the height of the three pointy towers.
For example, when the tower height is input as 3
, they would look something like this:
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
|///| |///| |///|
|// | |// | |// |
|/ | |/ | |/ |
Notice that each section of the tower is 3-tall. Also notice the pattern in the bottom section of the tower. This should scale with other sizes.
When it is 5
, they will grow to something like:
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
^^^^^^^ ^^^^^^^ ^^^^^^^
^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^
|///////| |///////| |///////|
|////// | |////// | |////// |
|///// | |///// | |///// |
|//// | |//// | |//// |
|/// | |/// | |/// |
You can (and should) start programming this assignment just accepting the tower height as input, and getting it to print out right. Once you do, you can move on to the next two inputs.
The tower separation input will control how far apart the towers are.
Say that the tower-height was input at 3
, and the separation was also 3
.
You should get:
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
|///| |///| |///|
|// | |// | |// |
|/ | |/ | |/ |
Notice how there are 3 blank spaces in-between each tower.
However, if tower-height is still 3
, but the separation is set to 10
, you should get:
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
|///| |///| |///|
|// | |// | |// |
|/ | |/ | |/ |
Now, there are 10 spaces between each.
The last input controls the height of the “main” castle, beneath the towers. For example, given the inputs:
Tower height: 3
Tower separation: 4
Main castle height: 1
You should get a castle that looks like so:
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
|///| |///| |///|
|// | |// | |// |
|/ | |/ | |/ |
| ~~~~~~ ~~~~~~ |
| |
~~~~~~~~~~~~~~~~~~~~~~~
Notice that the height of the base is 1 character (plus the top and bottom).
Below are several complete examples of what a correct program behavior would look like:
Tower height: 3
Tower separation: 4
Main castle height: 1
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
|///| |///| |///|
|// | |// | |// |
|/ | |/ | |/ |
| ~~~~~~ ~~~~~~ |
| |
~~~~~~~~~~~~~~~~~~~~~~~
Tower height: 7
Tower separation: 2
Main castle height: 2
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
^^^^^^^ ^^^^^^^ ^^^^^^^
^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^
^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^
^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^
|///////////| |///////////| |///////////|
|////////// | |////////// | |////////// |
|///////// | |///////// | |///////// |
|//////// | |//////// | |//////// |
|/////// | |/////// | |/////// |
|////// | |////// | |////// |
|///// | |///// | |///// |
| ~~~~ ~~~~ |
| |
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tower height: 3
Tower separation: 22
Main castle height: 3
^ ^ ^
^^^ ^^^ ^^^
^^^^^ ^^^^^ ^^^^^
|///| |///| |///|
|// | |// | |// |
|/ | |/ | |/ |
| ~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ |
| |
| |
| |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All of your code should be well-formatted and properly indented. You should follow a consistent style, and name your variables and function well. Your program file should have a header comment at the beginning of the following form:
#
# Author: Your name
# Description: A brief description of what your program does
#
This assignment is due on 2/3/2018 at 5:00pm. You should turn it in to the D2L dropbox before this time. Remember to name your file correctly.