{"id":15443833,"url":"https://github.com/zanderlewis/calculator-fortran","last_synced_at":"2026-03-18T17:25:58.824Z","repository":{"id":253846404,"uuid":"844710727","full_name":"zanderlewis/calculator-fortran","owner":"zanderlewis","description":"A simple calculator I created in Fortran","archived":false,"fork":false,"pushed_at":"2024-08-19T21:26:00.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T08:42:21.865Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Fortran","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zanderlewis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-19T20:19:38.000Z","updated_at":"2025-01-28T21:29:23.000Z","dependencies_parsed_at":"2024-08-21T01:17:52.140Z","dependency_job_id":null,"html_url":"https://github.com/zanderlewis/calculator-fortran","commit_stats":null,"previous_names":["zanderlewis/calculator-fortran"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fcalculator-fortran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fcalculator-fortran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fcalculator-fortran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zanderlewis%2Fcalculator-fortran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zanderlewis","download_url":"https://codeload.github.com/zanderlewis/calculator-fortran/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245991584,"owners_count":20706129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T19:37:07.700Z","updated_at":"2026-01-07T21:06:01.739Z","avatar_url":"https://github.com/zanderlewis.png","language":"Fortran","funding_links":[],"categories":[],"sub_categories":[],"readme":"# calculator-fortran\nA simple calculator I created in Fortran\n\n[![Build Fortran Code](https://github.com/zanderlewis/calculator-fortran/actions/workflows/build.yml/badge.svg)](https://github.com/zanderlewis/calculator-fortran/actions/workflows/build.yml)\n\n## How to run\n1. Clone the repository:\n```bash\ngit clone https://github.com/zanderlewis/calculator-fortran.git\ncd calculator-fortran\n```\n2. Run the following commands:\n```bash\ngfortran calculator.f90 -o calculator\n./calculator\n```\n3. Follow the on-screen instructions to use the calculator.\n\n## Understanding the code\n\n```fortran\ncharacter(len=20) :: result_str\ncharacter(len=*), parameter :: reset = char(27) // '[0m'\ncharacter(len=*), parameter :: red = char(27) // '[31m'\ncharacter(len=*), parameter :: yellow = char(27) // '[33m'\ncharacter(len=*), parameter :: green = char(27) // '[32m'\n```\n^ These lines define the colours used in the output of the program. ^\n\n```fortran\nprint *, yellow // 'Enter first number: ' // reset\nread *, num1\nprint *, yellow // 'Enter operator (+, -, *, /): ' // reset\nread *, operator\nprint *, yellow // 'Enter second number: ' // reset\nread *, num2\n```\n^ These lines prompt the user to enter the first number, operator, and second number. ^\n\n```fortran\nif (operator == '+') then\n    result = num1 + num2\nelse if (operator == '-') then\n    result = num1 - num2\nelse if (operator == '*') then\n    result = num1 * num2\nelse if (operator == '/') then\n    if (num2 == 0) then\n        ! Prevent division by zero\n        print *, red // 'Division by zero is prohibited' // reset\n        stop\n    end if\n    result = num1 / num2\nelse\n    print *, red // 'Invalid operator' // reset\n    stop\nend if\n```\n^ These lines calculate the result based on the operator entered by the user. ^\n\n```fortran\nwrite(result_str, '(F6.2)') result\nprint *, green // 'Result: ' // trim(result_str) // reset\n```\n^ These lines format and print the result to the console. ^\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanderlewis%2Fcalculator-fortran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzanderlewis%2Fcalculator-fortran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzanderlewis%2Fcalculator-fortran/lists"}