Skip to content

Adding a new Calculator contract#2

Open
BChainbuddy wants to merge 3 commits intogdsc-ipsacademy:mainfrom
BChainbuddy:calculations_contract
Open

Adding a new Calculator contract#2
BChainbuddy wants to merge 3 commits intogdsc-ipsacademy:mainfrom
BChainbuddy:calculations_contract

Conversation

@BChainbuddy
Copy link

Deployment of the contract Calculator

I worked on a new basic blockchain contract Simple Calculator...

Usage:

The calculator contract lets the user perform calculations on the preferred blockchain.

Key features

Addition

The user inputs the parameters a and b. The function adds a and b together.

    function add(uint256 a, uint256 b) public pure returns (uint256) {
        return a + b;
    }

Subtraction

The user inputs the parameters a and b. The function subtracts b from a.

    function subtract(uint256 a, uint256 b) public pure returns (uint256) {
        require(a >= b, "Subtraction underflow");
        return a - b;
    }

Multiplication

The user inputs the parameters a and b. The function multiplies a with b.

    function multiply(uint256 a, uint256 b) public pure returns (uint256) {
        return a * b;
    }

Divison

The user inputs the parameters a and b. The function divides a by b.

    function divide(uint256 a, uint256 b) public pure returns (uint256) {
        require(b != 0, "Division by zero");
        return a / b;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments