Create a class called Employee that contains 3 pieces of information as instance
ID: 3648996 • Letter: C
Question
Create a class called Employee that contains 3 pieces of information as instance variables: first name (datatype string), last name (datatype string), monthly salary.( datatype decimal).Your class should contain a constructor that initializes the 3 instance variables. It should also contain a property for each instance variable with get and set accessors. The property for salary should verify that the salary is greater than 0. If a negative value is passed in, the set accessor should set the salary to 0.
Create a second class EmployeeTest that creates two employee objects using the constructor that you developed in the Employee class. Display the name and salary for each Employee. Use the set property for salary to give each employee a 10% raise, Display the name and salary for each employee again
Explanation / Answer
Public Class Employee Public EmployeeNumber As Long Public FirstName As String Public LastName As String Public Title As String Public Sub New(Optional ByVal EmplNbr As Long = 0, Optional ByVal FName As String = "Unknown", Optional ByVal LName As String = " Not Specified", Optional ByVal Position As String = "Loan Specialist") EmployeeNumber = EmplNbr FirstName = FName LastName = LName Title = position End Sub Public Function GetEmployeeName() As String Return LastName + ", " + FirstName End Function End Class
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.