Homework
Homework — your app made of functions
Now — YOUR app. Rework it so that main only calls functions.
Requirements:
formatItem(...)— takes your 3 fields and returns astring(prints nothing).printItem(...)— callsformatItemand prints it.- At least one function with multiple returns — e.g.
perUnit(a, b int) (int, bool)over your numeric field. - Inside
main— only variables and function calls, noSprintf. - 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. ThenformatItem(it Item)— one parameter instead of three.