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.
git clone <REPO_URL>
cd calculator
Replace <REPO_URL> with your GitHub Classroom assignment link.
- If you want to use Java, keep
Main.javaand removemain.c,main.cpp, andmain.py. - If you want to use C, keep
main.cand removeMain.java,main.cpp, andmain.py. - If you want to use C++, keep
main.cppand removeMain.java,main.c, andmain.py. - If you want to use Python, keep
main.pyand removeMain.java,main.c, andmain.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.)
- Uncomment the section for your language in
run.sh. - Comment out or remove the other language sections.
-
Open your code file and complete the
add_numbers(oraddNumbers) 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
- For Java:
-
Check that
output.txtmatchesexpected_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
- On Mac/Linux (bash):
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:
- Go to the Actions tab of your GitHub repository.
- Click on the failed workflow run.
- 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!