Question

Create an add function should add two values sent to it. subtract function. A subtract function...

Create an add function should add two values sent to it. subtract function. A subtract function should subtract a received value from the value of 20. multiply function. A multiplication function should multiply the result from the add function times the result from the subtract function. A division function should divide the result from the add function by the result from the subtract function. Please make sure that division by zero does not occur, print error message instead. Use a PHP function (from PHP library). Ideally, this function would work with at least one other function from previous requirements or would add functionality to our current program. All of this should be in PHP (but you probably already knew that).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hey! Here is the code for the above question.

<?php
         
         function addFunction($num1, $num2) {

            return ($num1 + $num2);

         }

         function subtractFunction($num3) {

           return (20 - $num3);

         }

          function multiplicationFunction($num1,$num2,$num3) {

           $result = addFunction($num1,$num2) * subtractFunction($num3);
           return ($result);

         }
    
         
?>

Hope that solves the problem. Feel free to ask any queries in the comment section.

Keep Cheggin. Have a good day!

:)

Add a comment
Know the answer?
Add Answer to:
Create an add function should add two values sent to it. subtract function. A subtract function...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Calculator = 0.01 Calculate . Add O subtract O Multiply ODvide uttons on the right determine the operation that is perf...

    Calculator = 0.01 Calculate . Add O subtract O Multiply ODvide uttons on the right determine the operation that is performed on the numbers. For example, the following image shows values 12 and 3 are entered in the ion in selected. When the Calculate button is pressed, the result of the addition operation is shown after the equal sign ( In this example, the result is 1 Calculator 12 .15.01 Calculate | ⓔAdd subtract。Multiply O Divide g images show the...

  • Write the functions to add, subtract, multiply and divide two doubles. The function returns the result...

    Write the functions to add, subtract, multiply and divide two doubles. The function returns the result on the operation. Write a program to test your functions. In visual studios console application C#.

  • IN PYTHON! Create a calculator GUI. The GUI should let the user add, subtract, multiply, and...

    IN PYTHON! Create a calculator GUI. The GUI should let the user add, subtract, multiply, and divide two numbers they input. All user input and the result displayed to the user should be seen in the GUI itself (i.e. the terminal should not show anything). Thank you very much! PLEASE PASTE IN HERE THE RIGHT INDENTS

  • Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit...

    Write a calculator that will give the user this menu options: 1)Add 2)Subtract 3)Multiply 4)Divide 5)Exit . Your program should continue asking until the user chooses 5. If user chooses to exit give a goodbye message. After the user selections options 1 - 4, prompt the user for two numbers. Perform the requested mathematical operation on those two numbers. Round the result to 1 decimal place. Please answer in python and make it simple. Please implement proper indentation, not just...

  • Create a 'simple' calculator. The calculator should be able to add, subtract, multiply, and divide two...

    Create a 'simple' calculator. The calculator should be able to add, subtract, multiply, and divide two numbers. You can use whatever format you want to receive the numbers (such as textboxes). You also can use whatever method (such as a button for each operation +, -, *, /) to determine what operation the user wants to accomplish. The output should be displayed in a similar format to "1 + 2 = 3" or "1 - 2 = -1". Make sure...

  • SEE THE Q3 for actual question, The first Two are Q1 and Q2 answers . Q1...

    SEE THE Q3 for actual question, The first Two are Q1 and Q2 answers . Q1 #include<iostream> using namespace std; // add function that add two numbers void add(){    int num1,num2;    cout << "Enter two numbers "<< endl;    cout << "First :";    cin >> num1;    cout << "Second :";    cin >>num2;    int result=num1+num2;    cout << "The sum of " << num1 << " and "<< num2 <<" is = "<< result;   ...

  • Creating a Calculator Program

    Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...

  • Big Numbers Library The creators of C++ have created primitive data types to allow developers to store numbers of various size they expect most users will need. Such as short, int, double. In our c...

    Big Numbers Library The creators of C++ have created primitive data types to allow developers to store numbers of various size they expect most users will need. Such as short, int, double. In our case we want to expand on these primitive data types and allow users to store big numbers that can store up to 1,000 digits long. In order to do this, you will create a BigNumbers class, using TDD, Test Driven Development, that will use vectors from...

  • C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use...

    C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use functions. Use a custom library and namespace. Use reference variables as parameters to return values from functions. Create a robust user interface with input error checking. Use exceptions to indicate errors. Resources kishio.h kishio.cpp Assignment requirements You will need eight methods (including main). One is given to you. Their requirements are specified below: menu: The menu function takes no arguments, but returns a char...

  • Using C#, create a class in a file MathOP.cs. MathOP.cs needs to include the following methods MathAdd: to add two numb...

    Using C#, create a class in a file MathOP.cs. MathOP.cs needs to include the following methods MathAdd: to add two numbers MathSub: to subtract two numbers Next, create a new class MathOP2 (MathOP2.cs) that Inherits from MathOP.cs. MathOP2.cs needs to include the following methods MathMult: to multiply two numbers MathDiv: to divide two numbers Allinone: accepts two parameters and set 4 class variables: v_add, v_subtract, v_multiply, and v_divide and show how these values are retrieved. Finally, create a program TestMathOP.cs...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT