Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Pay Report in Swift.....getting closer to the answer still need to have format specifiers!!!

// Using the data below, create an appropriate and attractive pay report. Be sure to include //totals, labels, and headers. //Currency values should be formatted appropriately using String formatting.
tuples in the employees array contain the following data: (id, name, regular hours, overtime hours, holiday hours, pay scale) You can generate a string with formatted numeric output using the following: String(format: <format specifier>, arguments:<argument list>) Where:<argument list> alist of one or more variables enclosed in [] <format specifier>a string literal containing a format specifier as shown The format specifier has the following format: //%[0][width][.precision][type]

     let employees = [(100, "John", 35.0, 0.0, 0.0, 3),
                 (132, "Mark", 40.0, 5.0, 0.0, 2),
                 (210, "Susan", 40.0, 0.0, 0.0, 2),
                 (155, "Blake", 40.0, 20.0, 0.0, 1),
                 (349, "Thomas", 40.0, 5.0, 0.0, 2),
                 (349, "Connor", 40.0, 2.0, 3.0, 4),
                 (240, "Teri", 40.0, 5.0, 5.0, 2)]

let payScale = [1: 25.00, 2: 37.50, 3: 42.50, 4: 65.00]
     let overtimeRate = 1.5 
     let holidayRate = 2.0

```swift
ID     Name      Regular Hours   Overtime Hours    Holiday Hours    Pay Scale
100     John        35.0            0.0             0.0                 3
132     Mark        40.0            5.0             0.0                 2
210     Susan       40.0            0.0             0.0                 2
155     Blake       40.0            20.0                0.0                 1
349     Thomas      40.0            5.0             0.0                 2
349     Connor      40.0            2.0             3.0                 4
240     Teri        40.0            5.0             5.0                 2
Total: 
Total John        6875.0
Total Mark        10312.5
Total Susan        11687.5
Total Blake        17875.0

```code
let overtimeRate = 1.5
let holidayRate = 2.0
var regTotPay1 = 0.0
var regTotPay2 = 0.0
var regTotPay3 = 0.0
var regTotPay4 = 0.0

var TotalHours = 0.0
var TotalOvertme = 0.0
var totalHolHours = 0.0
var totalPayScaleOne = 0.0
var grandTotal = 0.0

print("ID",   "   ","Name", "    ","Regular Hours", " ", "Overtime Hours", "  ","Holiday Hours", "  ","Pay Scale")

for emp in employees {

    var id = emp.0
    var name = emp.1
    var reg = emp.2
    var over = emp.3
    var hol = emp.4
    var pay = emp.5
    var GrandTotal = reg

        (regTotPay1 += payScale[1]! * reg)
        (regTotPay2 += payScale[2]! * reg)
        (regTotPay3 += payScale[3]! * reg)
        (regTotPay4 += payScale[4]! * reg)

    print("\(id)" + "\t\t" + "\(name)" + "\t\t" + "\(reg)" + "\t\t\t" + "\(over)" + "\t\t\t\t" + "\(hol)" + "\t\t\t\t\t" + "\(pay)" )
    }