Question

Create a C# Console program. Add a class named Employee that has the following public fields:...

Create a C# Console program. Add a class named Employee that has the following public fields:

• Name. The name field references a String object that holds the employee’s name.

• IDNumber. The IDNumber is an int that holds the employee’s ID number.

• Department. The department field is a String that holds the name of the department where the employee works.

• Position. The position field is a String that holds the employee’s job title.

Once you have written the class, write a separate (main) program that creates three Employee objects to hold the following data:

Name ID Number Department       Position

Susan Meyers 47899 Accounting Vice President

Mark Jones 39119 IT Programmer

Joy Rogers 81774 Manufacturing Engineer

The program should:

  • Store this data in three employee objects
  • Display the data for each employee on the screen. You do not have to worry about table formatting.

Access the fields using variableName.fieldName. For example, in the main program:

{
Employee e1 = new Employee();
e1.Name = "Susan Meyers";
e1.IDNumber = 47899;
// and similar for department and position

// later

Console.WriteLine("Employee " + e1.Name + " : " + e1.IDNumber + " : " + e1.Department + " : " + e1.Position);
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Employee.cs

*************************************************************************************************************************************************

class Employee{
public string Name,Department,Position;
public int IDNumber;
}

**********************************************************************************************************************************************

main.cs

*********************************************************************************************************************************************

using System;
class HelloWorld {
static void Main() {
Employee e1 = new Employee(); //first employee object
e1.Name = "Susan Meyers";
e1.IDNumber = 47899;
e1.Department = "Accounting";
e1.Position = "Vice President";

  
  
Employee e2 = new Employee(); //second Employee object
e2.Name = "Mark Jones";
e2.IDNumber = 39119;
e2.Department = " IT";
e2.Position = "Programmer";

Employee e3 = new Employee(); //third Employee object
e3.Name = "Joy Rogers";
e3.IDNumber = 81774;
e3.Department = "Manufacturing";
e3.Position = "Engineer";

//print all object data
Console.WriteLine("Employee " + e1.Name + " : " + e1.IDNumber + " : " + e1.Department + " : " + e1.Position);
Console.WriteLine("Employee " + e2.Name + " : " + e2.IDNumber + " : " + e2.Department + " : " + e2.Position);
Console.WriteLine("Employee " + e3.Name + " : " + e3.IDNumber + " : " + e3.Department + " : " + e3.Position);
  
}
}

**********************************************************************************************************************************************

Screenshot of the code:

*********************************************************************************************************************************

output:

Add a comment
Know the answer?
Add Answer to:
Create a C# Console program. Add a class named Employee that has the following public fields:...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program Write a class named Employee that has the following member variables: name...

    Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...

  • Design and write a class named Employee that inherits the Person class from the previous exercise...

    Design and write a class named Employee that inherits the Person class from the previous exercise and holds the following additional data: ID number, department and job title. Once you have completed the Employee class, write a Python program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Phone Susan Meyers 47899 Accounting Vice President 212-555-1212 Mark Jones 39119 IT Programmer 212-555-2468 Joy Rogers 81774 Operations Engineer 212-555-9753 The Python program should store...

  • Using C++, Write a class named Employee that has the following member variables: name. A string...

    Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points...

    Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...

  • 1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are...

    1) Introduction to Objects (with Constructors and Properties) We need to answer the question which are below. and instruction are given down starting with part(b). Just we need to copy paste code file and follow the instruction and answer related to them. a) Enter the following program.Answer The questions below the codes, Notice that it consists of two classes that will go into the same project. Please put each class into its own code file (use Lab5_1 for the Project...

  • Design a Payroll class with the following fields:

    IN JAVADesign a Payroll class with the following fields:• name: a String containing the employee's name• idNumber: an int representing the employee's ID number• rate: a double containing the employee's hourly pay rate• hours: an int representing the number of hours this employee has workedThe class should also have the following methods:• Constructor: takes the employee's name and ID number as arguments• Accessors: allow access to all of the fields of the Payroll class• Mutators: let the user assign values...

  • 1. Write a class named Employee that holds the following data about an employee in attributes:...

    1. Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. (employee.py) 2. Create a UML diagram for Employee class. (word file) 3. Create a program that stores Employee objects in a dictionary. Use the employee ID number as the key. (employee_App.py) The program should present a menu that lets the user perform the following actions: ✓ Look up an employee in the dictionary ✔ Add a new...

  • c++ only Design a class representing an Employee. The employee would have at least these private...

    c++ only Design a class representing an Employee. The employee would have at least these private fields (Variables): name: string (char array) ID: string (char array) salary: float Type: string (char array) All the variables except for the salary should have their respective setters and getters, and the class should have two constructors, one is the default constructor and the other constructor initializes the name,ID and type of employee with valid user input. The class should have the following additional...

  • Create a date class with attributes of month, day, and year. Create an employee class for...

    Create a date class with attributes of month, day, and year. Create an employee class for storing information related to employee information for the CS1C Corporation. This class should contain the employee’s name, employee’s Id, phone number, age, gender, job title, salary, and hire date. You should write a series of member functions that change the employee’s name, employee’s Id, phone number, age, job title, salary, and hire date. You should use your date class (composition) when accessing hire date....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT