Question
C# programing Single inheritance-Part 2 Given two integer numbers N1 and N2, create a class 'ProblemSolution' with following characteristics. Must extend a 'Base' class. Create
C# programing
Single inheritance-Part 2
Given two integer numbers N1 and N2, create a class 'ProblemSolution' with following characteristics.
Must extend a 'Base' class.
Create a method 'solution' with two integer parameters (N1 and N2) and long return type.
The 'solution' method should call the addition and subtraction methods of 'Base' class and return multiplication of returned results of addition and subtraction method.
Result = (N1 + N2) * (N1 - N2)
What is inheritance? Inheritance is a mechanism in which one object acquires all the properties and behaviors of the parent object. Reference: https://www.javatpoint.com/c-sharp-inheritance
Input 50 10
Output 2400
Please fill in the partial code below
using System; using System.Collections.Generic; using System.Linq;
//write your code here
public class Base { public int addition (int N1, int N2) { int Z = N1 + N2; return Z; }
public int subtraction (int N1, int N2) { int Z = N1 - N2; return Z; } }
class DriverMain {
public static void Main () { int N1 = int.Parse (Console.ReadLine ()); int N2 = int.Parse (Console.ReadLine ()); ProblemSolution problemsolution = new ProblemSolution (); Console.WriteLine(problemsolution.solution (N1, N2)); } }
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