Exercises & activities from the go workshop provided by Packt: https://courses.packtpub.com/courses/go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

32 lines
506 B

package main
import "fmt"
func main() {
devSalary := salary(50, 2080, developerSalary)
bossSalary := salary(150000, 25000, managerSalary)
fmt.Printf("Boss salary: %d\n", bossSalary)
fmt.Printf("Developer salary: %d\n", devSalary)
}
func salary(x, y int, f func(int, int) int) int {
pay := f(x, y)
return pay
}
func developerSalary(hourlyRate, hoursWorked int) int {
return hourlyRate * hoursWorked
}
func managerSalary(baseSalary, bonus int) int {
return baseSalary + bonus
}