Question: C# Source Code Needed Objectives Learn the basics of recursion. Background I In this lab you'll write a calculator which calculates multiplication, division and modular

C# Source Code Needed  C# Source Code Needed Objectives Learn the basics of recursion. Background
I In this lab you'll write a calculator which calculates multiplication, division
and modular division using recursion. Tasks You'll need to write 3 methods,
all of which must use recurion: 1) Write recursive_multiply. It should take

Objectives Learn the basics of recursion. Background I In this lab you'll write a calculator which calculates multiplication, division and modular division using recursion. Tasks You'll need to write 3 methods, all of which must use recurion: 1) Write recursive_multiply. It should take in 2 integers and return an integer. Another way to say multiply 54. is 5+(503), or 5+5+(5*2), or 5+5+5+(5*1), or 5+5+5+5+(5*0). You know that any number multiplied by O is 0. 2) Write recursive_div. It should take in 2 integers and return an integer. Unlike regular division, div just returns the integer portion of division. It answer the question "how many times does the second number go into the first number". So, 7 div 3 = 2, because 3 goes in 2 times, the leftover is irrelevant to div. If you are asked to divide anything by 0, you should return-1, as that's an error. If you are asked to divide anything by itself, you should return 1. i.e. 7 div 7 = 1 If you are asked to divide a small number by a bigger one, the answer is 0. i.e. 2 div 7 =0 For all other numbers, you'll keep subtracting the second number from the first number, until the first number is less than the second. You'll count how many times this happens, and return that count. Remember you must use recursion in all 3 of these methods. 3) Write recursive_mod. It should take in 2 integers and return an integer. Mod only cares about the remainder of division. If you are asked to divide anything by 0, it should return -1, as that's an error. If you are asked to divide any smaller number by a larger number, you should return the smaller number. i.e. 2 mod 3 = 2 For all other cases, you'll keep subtracting the second number from the first. For example: 7 mod 3: 7-3=4 4-3 = 1 Answer is 1. 4) Finally, write the main method, which prompts the user to either multiply, div, or mod. Then prompt the user for 2 numbers, call the appropriate method, receive a result, and print it out. Continue to ask the user (you may use a loop here) until they choose 0 to quit. Sample Output: Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 1 Enter first number 3 Enter second number 5 Answer: 15 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers Enter first number 5 Enter second number 1 0 3. Answer: 0 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers Mod 2 numbers 2 Enter first number 15 Enter second number 5 Answer: 3 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 2 Enter first number 15 Enter second number 2 Answer: 7 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 2 Enter first number 15 Enter second number 0 Answer: -1 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 2 Enter first number 2 Enter second number 10 Answer: 0 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 3 Enter first number 7 Enter second number 2 Answer: 1 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 3 Enter first number 10 Enter second number 3 Answer: 1 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 3 Enter first number 10 Enter second number 0 Answer: -1 Choose from the following: 0. Quit 1. Multiply 2 numbers 2. Div 2 numbers 3. Mod 2 numbers 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!