Knowee
Questions
Features
Study Tools

Create a mini calculator application, which has following functionalitiesAdditionSubtractionDivisionMultiplicationYour app should haveTwo input boxes which should take two numbers from the user.Four Buttons with following text contentAddSubtractDivideMultiplyWhen user enter 2 and 4 and clicks on multiply button, an alert should come with 8 as ansWhen user enter 8 and 4 and clicks on Divide button,an alert should come with 2 as ans

Question

Create a mini calculator application, which has following functionalitiesAdditionSubtractionDivisionMultiplicationYour app should haveTwo input boxes which should take two numbers from the user.Four Buttons with following text contentAddSubtractDivideMultiplyWhen user enter 2 and 4 and clicks on multiply button, an alert should come with 8 as ansWhen user enter 8 and 4 and clicks on Divide button,an alert should come with 2 as ans

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple implementation of a mini calculator application using HTML, CSS, and JavaScript:

HTML:

<!DOCTYPE html>
<html>
<head>
    <title>Mini Calculator</title>
</head>
<body>
    <input type="number" id="num1" placeholder="Enter first number">
    <input type="number" id="num2" placeholder="Enter second number">
    <button onclick="add()">Add</button>
    <button onclick="subtract()">Subtract</button>
    <button onclick="multiply()">Multiply</button>
    <button onclick="divide()">Divide</button>
</body>
</html>

JavaScript:

function add() {
    var num1 = document.getElementById('num1').value;
    var num2 = document.getElementById('num2').value;
    alert(Number(num1) + Number(num2));
}

function subtract() {
    var num1 = document.getElementById('num1').value;
    var num2 = document.getElementById('num2').value;
    alert(Number(num1) - Number(num2));
}

function multiply() {
    var num1 = document.getElementById('num1').value;
    var num2 = document.getElementById('num2').value;
    alert(Number(num1) * Number(num2));
}

function divide() {
    var num1 = document.getElementById('num1').value;
    var num2 = document.getElementById('num2').value;
    if (num2 != 0) {
        alert(Number(num1) / Number(num2));
    } else {
        alert("Cannot divide by zero");
    }
}

This code creates a simple calculator with two input fields for the numbers and four buttons for the operations. When a button is clicked, the corresponding function is called, which reads the values from the input fields, performs the operation, and then displays the result in an alert box.

This problem has been solved

Similar Questions

Create a mini calculator which has the ability to add, subtract, multiply and divide. Follow the steps below to complete this assignment.Step 1: Your code should be able to add, subtract, divide and multiplyStep 2: Your program should ask the user for two numbers.Step 3: Your code should calculate and print the output for all the calculations. Use appropriate variables and output names.

Create a program that prompts you for two numbers (positive or negative values should be possible), multiplies them and then adds a third number that also must be entered.

SimpleCalculatorCreate a class SimpleCalculator that supports basic arithmetic operations: addition, subtraction, multiplication, and division.Implement methods for each operation.Constraints:NAExample:Sample Input:56Sample Output:Addition: 12Subtraction: -2Multiplication: 35Division: 0.714286Explanation:Take two inputs and perform above arithmetic operations inside a class.

Write a java application that accepts two values from the keyboard using input dialog box,theprogram should compute the same of the numbers and display the results on a message dialogbox.

rite code that allow the user to input a number. Use for loop to print the number and 4 numbers after this number the user. For example, if the input is 5, then the program should print:56789

1/2

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.