Answer to Question #235948 in C# for AhsanAzam

Question #235948

Design a c# console Application that will output the salary sum of two employees

. Your program must do the following :

 

·   Create an abstract data type, Emp. with two private data members Sal. (Type Double) and name (Type String).

·   Include  a  constructor  in  the  Emp  class  to  initialize  all  private  data members with caller-supplied values (in addition to the default constructor!)

·   Overload the + operator to return the sum of two Emp objects.

·   Your OutPut Should be like:

·   Sum of Employees Salary : Shaban, khurrum = 450000.


1
Expert's answer
2021-09-11T23:39:38-0400
using System;

namespace ConsoleApplication1
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            var date1 = new Data(5, 6, 7);
            var date2 = new Data(3, 4, 5);

            var date3 = date1 + date2;
            date3.Display();
        }
    }

    class Data
    {
        public int Day;
        public int Month;
        public int Year;

        public Data()
        {
            Day = 0;
            Month = 0;
            Year = 0;
        }
        
        public Data(int d, int m, int y)
        {
            Day = d;
            Month = m;
            Year = y;
        }

        public void Display()
        {
            Console.WriteLine($"{Day}/{Month}/{Year}");
        }
        
        public static Data operator +(Data d1, Data d2)
        {
            return new Data(d1.Day + d2.Day, d1.Month + d2.Month, d1.Year + d2.Year);
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS