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...

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

    Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. Don't include a constructor or any other methods. Written in Python and formatted like it says below!!!!! Once you have written the class, write a program that creates three Employee objects to hold the following data: Name ID Number Department Job Title Susan Meyers 47899 Accounting Vice President Mark Jones 39119 IT Programmer Joy Rogers 81774 Manufacturing Engineering...

  • 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...

  • Part 1 (employee.py): Write a class name Employee that holds the following data about an employee...

    Part 1 (employee.py): Write a class name Employee that holds the following data about an employee in attributes:name, ID number, department and job title. Once you have written the class, write a program that creates three Employee objects to hold the following data: The program should store this data in the three objects, then display the data for each employee on the screen as a table like this (Use fstring or "format" function to format the output as a table,...

  • 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...

  • IN JAVA Ask the user for three employees. Store the data into three employee objects (use...

    IN JAVA Ask the user for three employees. Store the data into three employee objects (use the Employee class from the previous question). Display those employees in a table. On this question, you'll submit two files: Employee.java and some other file that has a main. Standard Input                 Bill Gates 1234 Engineering Engineer Elon Musk 4443 Business CEO Steve Jobs 9999 Creative Designer Required Output -- Employee Entry Form --\n Enter name\n Enter ID\n Enter department\n Enter position\n -- Employee...

  • 4. RetailItem Class Write a class named RetailItem that holds data about an item in a...

    4. RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the item. • unitsOnHand. The unitsOnHand field is an int variable that holds the number of units currently in inventory. • price. The price field is a double that holds the item’s retail price. Write a constructor that accepts arguments...

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