# Common format specifiers
# -----------------------------------
# %-10s # Left-aligned string, width 10
# %10s # Right-aligned string, width 10
# %5d # Integer, width 5
# %08d # Integer, width 8, padded with zeros
# %12.2f # Float, width 12, 2 decimal places
#
# Formats a record using fixed-width fields.
#
# %-15s = left-aligned string, width 15
# %10d = right-aligned integer, width 10
# %12.2f = right-aligned float, width 12,
# with 2 digits after the decimal point
def format_record(name, age, salary)
sprintf("%-15s%10d%12.2f", name, age, salary)
end
# Store the formatted string in a variable
result = format_record("Nicola", 27, 95_000.0)
puts result
# run:
#
# Nicola 27 95000.00
#