Start learning free

LESSON 55 OF 404 · CALCULATIONS - CHALLENGES

Employee of the Year V1 - Project in Go

Practice

Compute an end-of-year performance bonus for one employee, then print the employee's name and the bonus.

You start with:

name := "John Doe"
productivity := 83
salary := 135000
_ = productivity

Build:

John Doe
Bonus: $20250

Rules:

  • The bonus is 15% of the salary, rounded down to a whole number.
  • Print the employee's name on the first line.
  • Print the bonus on the second line as "Bonus: $<amount>".
  • productivity is not used in this version. It is there for the next versions, where you will compare employees by productivity.

Dividing two whole numbers (int) drops the fraction, so salary * 15 / 100 is already rounded down: bonus := salary * 15 / 100

Join text and a number with strconv.Itoa: fmt.Println("Bonus: $" + strconv.Itoa(bonus))

name := "John Doe"
productivity := 83
salary := 135000
_ = productivity

bonus := salary * 15 / 100
fmt.Println(name)
fmt.Println("Bonus: $" + strconv.Itoa(bonus))

STEP 1 OF 3
    Ctrl + Enter to check

    Employee Of The Year V1 in Go

    Keep going with GoAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free