This is a piece of code that I am using to check my calculations, I am simply writing out these values into the console in Xcode. Each of the arrays is declared with the values that are shown below.
var water_deficit: [Int] = []
The program calculates values for water deficit and appends them into this list (the calculations are not shown)
let months = ["January","Feburary","March","April","May","June","July","August","September","October","November","December"]
let rainfall = [38,94,142,149,236,305,202,82,139,222,178,103]
let raindays = [3,6,8,7,12,16,10,8,12,14,11,7]
for i in 0...11 {
println("\(months[i]) \t \(rainfall[i]) \t \(raindays[i]) \t \(water_deficit[i])")
}
The output as shown on the console:
Month Rainfall Raindays Water Deficit
January 38 3 38
Feburary 94 6 -18
March 142 8 -8
April 149 7 -1
May 236 12 116
June 305 16 301
July 202 10 202
August 82 8 82
September 139 12 101
October 222 14 203
November 178 11 208
December 103 7 103
As you can see, because the length of the words/numbers are different, the columns are offset. What do I need to do to generate columns of a specific width to avoid this problem?