Print a Big Diamond of Variable Size
Explore how to create a variable-sized diamond pattern in Ruby by reading user input, handling data type conversions, and controlling loops. Understand splitting the pattern into top and bottom parts, and practice string and integer operations to develop foundational programming skills.
Problem
Ask the user for the size of the diamond (based on the total number of rows) and then print out a diamond shape using hash characters #.
Enter the maximum number of rows (odd number): 9#########################################
Diamond of variable size
Purpose
Read user’s input into a variable
Convert a string to an integer
Use a variable with a
timesto loop
Analyze
The size of the diamond is not fixed, it ...