Homework

Homework — your app made of functions

Now — YOUR app. Rework it so that main only calls functions.

Requirements:

  1. formatItem(...) — takes your 3 fields and returns a string (prints nothing).
  2. printItem(...) — calls formatItem and prints it.
  3. At least one function with multiple returns — e.g. perUnit(a, b int) (int, bool) over your numeric field.
  4. Inside main — only variables and function calls, no Sprintf.
  5. The output is identical to your lesson-2 output (a refactor does not change behavior).

To submit: the code file + the program's output.

Tip. Noticed how every function drags the same three parameters around (title, pages, read)? Three loose variables travelling together everywhere — that is a signal. Next lesson they collapse into one record: type Item struct. Then formatItem(it Item) — one parameter instead of three.