Question

Please write in C# and create a UML design. 1. Create an Employee class. Items to...

Please write in C# and create a UML design.

1. Create an Employee class. Items to include as data members are employee number, first name, last name, and monthly salary. Include default and overloading constructors , also include a method that calculates the annual pay of the employee, and a method to display the information of the employee. Create a second class to test your Employee class by instantiating two Employee objects and display all the above information of each individual.

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EmployeeDetails
{
class Employee
{
public string fname,lname;
public int eno;
public double monthlySal, annualSal;

public Employee()
{
eno = 1;
fname = "Pravin";
lname = "Aute";
monthlySal = 50000;
}

public Employee(int no, string fnm, string lnm, double mpay)
{
eno = no;
fname = fnm;
lname = lnm;
monthlySal = mpay;
}
public void employeeInfo()
{
Console.WriteLine("Employee No : "+eno);
Console.WriteLine("Employee First Name : "+fname);
Console.WriteLine("Employee Last Name : "+lname);
Console.WriteLine("Employee Monthly salary : "+monthlySal );
}
public void calculateAnnualPay()
{
annualSal = monthlySal * 12;
Console.WriteLine("Annual Pay : "+annualSal );
}
}
class Test

{
static void Main(string[] args)
{
Console.WriteLine("Employee Object (DefaultConstructor) : 1");
Employee emp1 = new Employee();
emp1.employeeInfo();
emp1.calculateAnnualPay();
Console.WriteLine(Environment.NewLine );
Console.WriteLine("Employee Object (Parameterized Constructor) : 2");
Console.Write("Enter employee No : ");
int no = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter employee first name : ");
string fnm = Console.ReadLine();
Console.Write("Enter employee last name : ");
string lnm = Console.ReadLine();
Console.Write("Enter empployee monthly salary : ");
double msal = Convert.ToDouble(Console.ReadLine());

Employee emp2 = new Employee(no,fnm,lnm,msal );
emp2.employeeInfo();
emp2.calculateAnnualPay();


Console.ReadKey();
}
}
}

Add a comment
Know the answer?
Add Answer to:
Please write in C# and create a UML design. 1. Create an Employee class. Items to...
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
  • Within c++ Create a simple Employee class with name, department, and title. Create an hourlyEmployee class...

    Within c++ Create a simple Employee class with name, department, and title. Create an hourlyEmployee class (which inherits from the Employee class) for a basic payroll program to compute the net pay salary of hourly based employees. Your program should also find the average net pay for a small company. To define the class, include the appropriate data members, member functions, constructors, and access modifiers. For simplicity, use a constant tax rate of 30% to compute the tax amount. Employees...

  • Create a Java application, that support the following: Create an Employee class, which holds following information:...

    Create a Java application, that support the following: Create an Employee class, which holds following information: Employee First Name Employee Last Name Employee Phone Number Employee Address Employee id Employee Title Employee salary Create an application that uses the Employee class Constructors –Getters and setters A minimum of 3 constructors including default constructor equals() method Helper methods toString() method Create an array of 5 Employee objects Use a Scanner to read in 5 employee information Change 2 employees information (3-items...

  • C++ Design: Create a UML Class diagram that reflects the software design of your entire program...

    C++ Design: Create a UML Class diagram that reflects the software design of your entire program Q3. Create a class called Passenger that represents passengers of an airline company. A passenger is defined by the following information: - Passenger ID (int) - Name (string) - Address (string) - Tel (string) - Date of birth (of type Date from Q2) Provide the following functions: - A constructor that initializes the data members and provides default arguments. - Accessor methods that return...

  • Please create a UML for a class called Employee It will have a lastName as a...

    Please create a UML for a class called Employee It will have a lastName as a String It will have a salary as a double It will have vacDays as an int It will have a no argument constructor that sets lastName to null, salary to 0.0 and vacation days to 15 It will have an argument constructor. It will have 3 accessor and 3 mutator methods It will have a showInfo() as a void method to display all the...

  • E2a: Create a class called Employee that includes three pieces of information as data members---a first...

    E2a: Create a class called Employee that includes three pieces of information as data members---a first name (char array), last name (char array) and a monthly salary (integer). Your class should have a constructor that initializes the three data members. If the monthly salary is not positive, set it to 0. Write a test program that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10 percent raise and display...

  • 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 UML diagram to help design the class described in exercise 3 below. Do this...

    Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...

  • Create a class called Employee that includes three instance variables—a first name, a last name, and...

    Create a class called Employee that includes three instance variables—a first name, a last name, and a monthly salary. Code the default (no-args, empty) constructor. Provide a set and a get method for each instance variable. If the monthly salary is not positive, do not set its value.

  • 0.Use Factory Design Method 1. Implement an interface called EmployeeInfo with the following constant variables: FACULTY_MONTHLY_SALARY...

    0.Use Factory Design Method 1. Implement an interface called EmployeeInfo with the following constant variables: FACULTY_MONTHLY_SALARY = 6000.00 STAFF_MONTHLY_HOURS_WORKED = 160 2. Implement an abstract class Employee with the following requirements: Attributes last name (String) first name (String) ID number (String) Sex - M or F Birth date - Use the Calendar Java class to create a date object Default argument constructor and argument constructors. Public methods toString - returning a string with the following format: ID Employee number :_________...

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