Skip to content

Latest commit

 

History

History
80 lines (59 loc) · 2.5 KB

File metadata and controls

80 lines (59 loc) · 2.5 KB

Calculator Assignment (GitHub Classroom)

This repository is a template for a simple calculator assignment. Students can choose their preferred language (Python, C, C++, or Java) and implement the required function.

Getting Started

1. Clone the Repository

git clone <REPO_URL>
cd calculator

Replace <REPO_URL> with your GitHub Classroom assignment link.

2. Select Your Language

  • If you want to use Java, keep Main.java and remove main.c, main.cpp, and main.py.
  • If you want to use C, keep main.c and remove Main.java, main.cpp, and main.py.
  • If you want to use C++, keep main.cpp and remove Main.java, main.c, and main.py.
  • If you want to use Python, keep main.py and remove Main.java, main.c, and main.cpp.

You can delete files using:

del main.c main.cpp main.py   # On Windows
rm main.c main.cpp main.py    # On Mac/Linux

(Adjust the command for your OS and language choice.)

3. Update run.sh

  • Uncomment the section for your language in run.sh.
  • Comment out or remove the other language sections.

4. Implement and Test

  • Open your code file and complete the add_numbers (or addNumbers) function.

  • Test your code locally:

    • For Java: javac Main.java && java Main
    • For C: gcc -O2 main.c -o calculator && ./calculator
    • For C++: g++ -O2 -std=c++17 main.cpp -o calculator && ./calculator
    • For Python: python main.py
  • Check that output.txt matches expected_output.txt:

    • On Mac/Linux (bash):
      diff -wB output.txt expected_output.txt
      
    • On Windows (PowerShell):
      fc.exe /W output.txt expected_output.txt
      
    • On Windows (Git Bash):
      diff -wB output.txt expected_output.txt
      

5. Push Your Solution

git add .
git commit -m "Complete calculator assignment in <your language>"
git push origin main

Once you push your code, GitHub Classroom will automatically run autograding tests. You can see the results in your repository's commit history:

  • A green check mark (✓) means your code passed all tests.
  • A red cross (✕) means some tests failed.

To view detailed error messages:

  1. Go to the Actions tab of your GitHub repository.
  2. Click on the failed workflow run.
  3. Review the output to see what went wrong.

Note: Do not use any third-party libraries for this project. The goal is to help you understand how computers work internally by implementing everything yourself.


Good luck!