Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your functions should output the results using the console.WriteLine() function . USING C# MyMathFunction Write a function that takes in two numbers and a function

Your functions should output the results using the console.WriteLine() function.

USING C#

MyMathFunction

Write a function that takes in two numbers and a function name. The function should call the function name in the parameter passing it the two number to perform a math operation and returning the result. Your MyMathFunction should be able to handle 4 different math operations (add, subtract, divide, and multiply). You must write 5 functions to complete this assignment correctly (MyMathFunction, Add, Subtract, Multiply, Divide). Hint: Do not pass the function name as a string. Look at Delegates.

MyMathFunction(10, 10, Multiply);

100

MyMathFunction(50, 10, Divide);

5

MyMathFunction(10, 0, Divide);

Cannot Divide by 0!

MyMathFunction(20, 25, Add);

45

MyMathFunction(25, 20, Subtract);

5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions