Java homework tasks