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 each Employee’s yearly salary again.
Sample output:
Your solution:
#source code in java
Employee.java
import java.util.*;
import java.lang.*;
class Employee{
String first_name;
String last_name;
int salary;
static int i=1;
static int j=1;
Employee(String first,String last,int sal){
this.first_name=first;
this.last_name=last;
this.salary=sal;
}
void display(){
if(salary<0){
System.out.println("Employee
"+i+":"+first_name+" "+last_name+" Salary:"+0*12);
i=i+1;
}
else{
System.out.println("Employee
"+i+":"+first_name+" "+last_name+" Salary:"+salary*12);
i=i+1;
}
}
void display2(){
if(salary<0){
System.out.println("Employee
"+j+":"+first_name+" "+last_name+" Salary:"+0*12);
j=j+1;
}
else{
double x=0.1;
double
temp=0.1*(double)salary;
System.out.println("Employee
"+j+":"+first_name+" "+last_name+"
Salary:"+(salary+(int)temp)*12);
j=j+1;
}
}
public static void main(String args[]){
Employee a=new
Employee("Bob","Jones",2875);
Employee b=new
Employee("Susan","baker",3150);
a.display();
b.display();
System.out.println("\nIncreasing
Employee Salaries by 10%\n");
a.display2();
b.display2();
}
}
#output:
#if you have any doubt comment below....
E2a: Create a class called Employee that includes three pieces of information as data members---a first...
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...
In one file create an Employee class as per the following specifications: three private instance variables: name (String), startingSalary (int), yearlyIncrement (int) a single constructor with three arguments: the name, the starting salary, and the yearly increment. In the constructor, initialize the instance variables with the provided values. get and set methods for each of the instance variables. A computation method, computeCurrentSalary, that takes the number of years in service as its argument. The method returns the current salary using...
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.
In Java: Executable Class create an array of Employee objects. You can copy the array you made for Chapter 20. create an ArrayList of Employee objects from that array. use an enhanced for loop to print all employees as shown in the sample output. create a TreeMap that uses Strings for keys and Employees as values. this TreeMap should map Employee ID numbers to their associated Employees. process the ArrayList to add elements to this map. print all employees in...
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...
Part (A) Note: This class must be created in a separate cpp file Create a class Employee with the following attributes and operations: Attributes (Data members): i. An array to store the employee name. The length of this array is 256 bytes. ii. An array to store the company name. The length of this array is 256 bytes. iii. An array to store the department name. The length of this array is 256 bytes. iv. An unsigned integer to store...
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....
In JAVA 1. Create a class called Rectangle that has integer data members named - length and width. Your class should have a default constructor (no arg constructor) Rectangle() that initializes the two instance variables of the object Rect1. The second overloading constructor should initializes the value of the second object Rect2. The class should have a member function named GetWidth() and GetLength() that display rectangle's length and width. OUTPUT: Rectl width: 5 Rectl length: 10 Enter a width :...
Visual C# C# Visual Studio 2017 You are to create a class object called “Employee” which included eight private variables - firstN - lastN - idNum -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: -...
project-8c Write a class named Employee that has data members for an employee's name, ID_number, salary, and email_address (you must use those names - don't make them private). Write a function named make_employee_dict that takes as parameters a list of names, a list of ID numbers, a list of salaries and a list of email addresses (which are all the same length). The function should take the first value of each list and use them to create an Employee object....