Apply what you understand

A reusable study-plan calculation

A working program is the beginning. Explain your decisions and show evidence that they hold up.

The challenge

Build and test a small lesson-count component. Start with the nested function; optionally extract it into an Ada package in a local multi-file project.

Evidence to include

  • State the Total/Done policy without referring to source code.
  • Check (0,0), (4,0), (4,3), (4,4), and (4,5).
  • Explain why the subtraction is reached only when Done is below Total.
  • Keep calculation separate from output.
  • Include a review note explaining one design choice and one limitation.
Starter code
with Ada.Text_IO;

procedure Main is
   function Remaining (Total, Done : Natural) return Natural is
   begin
      if Done >= Total then
         return 0;
      end if;
      return Total - Done;
   end Remaining;
begin
   Ada.Text_IO.Put_Line (Natural'Image (Remaining (4, 1)));
end Main;

Save your practice

Sign in to save a project submission.