Same program, better structure — break main() into methods
Workbook 1c, p.119 — Project name: payroll-calculator-2
You already built a payroll calculator. Now reorganize it. The program does the exact same thing —
but instead of having all the code inside main(), break it into separate methods. Each method
should do ONE job: one gets input, one calculates pay, one displays results.
The output doesn't change — only the structure of your code does.
Run 1 — With Overtime
40 regular hours at $20 = $800, plus 5 overtime hours at $30 (1.5x) = $150. Total: $950.00
Run 2 — No Overtime
35 hours at $15 = $525.00. No overtime because hours did not exceed 40.
This exercise reinforces these concepts from Week 1:
main() reads like a story, anyone can understand
what the program does without reading every detail.
main() should read like a story —
each method call describes what happens next. The details live inside each method,
not all crammed into one place.
Workbook 1c, p.119 — Exercises: Calculator with Methods (Exercise 2)