Question

Write program in C#. WAP on Encapsulation to hide the type members with private access and...

Write program in C#.

WAP on Encapsulation to hide the type members with private access and display employee details.
• Create a new project, select console application from the template and name the project as
“EmployeeDetails.cs”.
• Here type members are nothing but properties.
• Create another class as Employee and write the properties for EmpId, EmpName and Salary.
• Now, create an instance of the Employee class in the “EmployeeDetails” class and assign the values for
EmpId,EmpName and Salary and print the values.

Homework Answers

Answer #1

HELLO,

I AM ATTACHING THE CODE IN C#

PLEASE GO THROUGH IT ONCE AND IF STILL HAVE ANY DOUBT FEEL FREE TO ASK IN COMMENT

AND IF THIS HELPS YOU PLEASE UPVOTE THE ANSWER

using System;

namespace EmployeeDetails
{
    class EmployeeDetails
    {
        static void Main(string[] args)
        {
            Employee emp = new Employee();
            emp.EmpId = 1;
            emp.EmpName = "ABC NAME";
            emp.Salary = 5000;

            Console.WriteLine("Employee Id :"+emp.EmpId);
            Console.WriteLine("Employee Name :" + emp.EmpName);
            Console.WriteLine("Employee Salary :" + emp.Salary);
        }
    }
    class Employee
    {
        public int EmpId;
        public string EmpName;
        public decimal Salary;
    }
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
write a c++ program A class called car (as shown in the class diagram) contains: o...
write a c++ program A class called car (as shown in the class diagram) contains: o Four private variables: carId (int), carType (String), carSpeed (int) and numOfCars (int). numOfCars is a static counter that should be  Incremented whenever a new Car object is created.  Decremented whenever a Car object is destructed. o Two constructors (parametrized and copy constructor) and one destructor. o Getters and setters for the Car type, ID, and speed. And static getter function for numOfCars....
C# Step 1: Create a Windows Forms Application. Step 2: Create a BankAccount class. Include: Private...
C# Step 1: Create a Windows Forms Application. Step 2: Create a BankAccount class. Include: Private data fields to store the account holder's name and the account balance A constructor with 0 arguments A constructor with 1 argument (account holder's name) A constructor with 2 arguments(account holder's name and account balance) Public properties for the account holder's name and the account balance. Do not use auto-implemented properties. A method to increase the balance (deposit) A method to decrease the balance...
Create a Software Application for XYZ Bank that allows its members to access their bank account...
Create a Software Application for XYZ Bank that allows its members to access their bank account information through an “ATM like” interface. The Menu Options should include: checking the account balance, debiting the account and crediting the account, along with an option to exit the program. Create an Account Class to represent the customers’ bank accounts. Include a data member of type float to represent the account balance. Provide a constructor that receives an initial balance and uses it to...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Create a C# application You are to create a class object called “Employee” which included eight...
Create a C# application You are to create a class object called “Employee” which included eight private variables: firstN lastN dNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week. regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:  constructor  properties  CalcPay(): Calculate the regular...
Payroll Management System C++ The project has multiple classes and sub-classes with numerous features within them....
Payroll Management System C++ The project has multiple classes and sub-classes with numerous features within them. Basic operations users can perform via this program project that are based on file handling are adding new employee record, modifying employee record and deleting record, displaying one or all employee’s record. Besides these, payroll management also allows users to print the salary slip for a particular employee. Features: 1. Addition of New Employee: You can find this feature under the public category of...
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's...
Lab: RectClass (constructor) Code in C++ This program creates a Rectangle object, then displays the rectangle's length, width, and area Define an overloaded constructor and use it when creating the Rectangle object instead of using the setters. Change this program to calculate and display the rectangle's perimeter. Example: In feet, how wide is your house? 20 In feet, how long is your house? 25 The house is 20.00 feet wide. The house is 25.00 feet long. The house has 500.00...
In C#, Write an application to determine the bonus of a sales person. The sales person...
In C#, Write an application to determine the bonus of a sales person. The sales person receives a 5% bonus on sales $1,000,000 or over and 4% of sales under $1,000,000. They also receive an additional bonus for their pay code. Pay code 1 additional $2500, pay code 2 additional $2000, pay code 3 additional $1500, and pay code 4 additional $1000. The user will be prompted to enter the salesperson’s name, sales, and code. Create a class to calculate...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....