Question
heres the code so far #include using namespace std; class Calculator{ public: calculator(){ cout int Calculator::addition(int a, int b){ return (a+b); } int Calculator::subtraction(int a,
heres the code so far
#include
using namespace std;
class Calculator{ public: calculator(){ cout
int Calculator::addition(int a, int b){ return (a+b); }
int Calculator::subtraction(int a, int b){ return (a-b); }
int Calculator::multiplication(int a, int b){ return (a*b); }
float Calculator::division(int a, int b){ return (a*1.0/b); }
int main(){ Calculator myCalculator; //change the class name to CalculatorWithMod when you finish your modifications int x, y; cout > x; cout > y; cout Modify the code: Create a new class called CalculatorWith Mod. This class should be a sub class of the base class Calculator. This class should also have an additional method for calculating the modulo. The modulo method should only be seen at the sub class, and not the base class! Include exception handling for instances when dividing by 0 or calculating the modulo with 0. You would need to use throw, try, and catch. The modulo (or "modulus" or "mod") is the remainder after dividing one number by another. Example: 20 mod 3 equals 2 Because 20/3 = 6 with a remainder of 2 See the sample outputs below: Input 1st integer: 12 Input 2nd integer: -5 The sum is 7 The difference is 17 The product is -60 The quotient is -2.4 The modulo is 2 Input 1st integer: 5 Input and integer: 0 The sum is 5 The difference is 5 The product is o Division by zero! Answer is undefined... Modulo by zero! Answer is undefined... Process exited after 6.722 seconds with return value o Process exited after 1.854 seconds with return value o Press any key to continue. Press any key to continue. Submit here your modified program code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started