Programming Project 01: Calculator

Overview

For this homework, you will be building a simple calculator with the following functions:

  • A display row showing the result of the most recent operation.

  • Plus and minus buttons that allow you to add/subtract a new number from the current total. When one of the two operation buttons is pressed, it should change colors and the other should remain the default color. Any button press that is not the currently selected operation (so a number or another operation) should reset its color (ex. if you press +, it should change color, and then go back to the default color when any other button is pressed).

  • After an operation is pressed, if the next button is a digit then the new digit should be displayed, along with any digits that follow. As soon as either the equals button or another operation button is pressed, the display row should update with the new total.

  • An equals button that immediately executes whatever operation was chosen previously, and display the updated total in the row, after a SHORT button press.

  • The equals button should also CLEAR the row and operation after a LONG button press. After clearing the display, make a Toast notifying the user that the screen has been cleared.

See gif below for sample functionality

Tips

  • The current total should initialize and clear to 00

  • All the operations are integer based, so no need for decimals or doubles.

  • After an operation has been pressed, if a new number is inputted and a different operation is pressed, the screen should still update as if an equal was pressed in between. 4+5−4 + 5 - should end as 99 , and 4+5−10+4 + 5 - 10 + should end as −1-1 .

  • Equals just has to execute the current operation once, it doesn't have to update anything upon later presses. For example, 1+2=1 + 2 = should display 1,2,1, 2, and then 33 . 1+2==1 + 2 = = should also display 1,2,1, 2, and then 33 . 1+2=+3=1 + 2 = + 3 = should end up displaying 66 .

  • Take out a calculator and check out how it functions!

Grading

  • Layout - 40%: Does the calculator have all the needed buttons? Are they aligned well and work on different sized devices?

  • Logic - 30%: Does the calculator work as expected? Does it have all of the necessary functionality?

  • Design - 10%: Did you customize the theme/style? Does the calculator look good?

  • Code Style - 20%: See the style section below

  • Extra Credit:

    • Make your calculator look better than the example. The customization has to be complicated and more than making small changes like simply changing the default theme colors or changing text size.

    • Add more functionality to your calculator (eg. multiplication, division, decimal points, negative numbers, etc).

    • GitHub submission (ex. commit messages are informative, using the correct directory for submission, etc.)

    Extra points will be given based on the difficulty of your extra implementations.

Code Style

You will be graded on

  1. Your code is easy to understand. This includes the naming of file, variable, and method names.

  2. Logic is not duplicated (ie. Don't have 10 separate methods that essentially do the same thing. Think about how you can write less code to accomplish more).

  3. Are you referring to strings via the strings.xml file?

Deliverables

  • Project GitHub link submitted to CANVAS page

  • Readme.txt file for more instructions

Last updated

Was this helpful?