Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 2: Create two simple classes; Employee and EmployeeData. The Employee class should have 4 instance variables; name, age, citizenship, and salary. The EmployeeData should

Question 2: Create two simple classes; Employee and EmployeeData. The Employee class should have 4 instance variables; name, age, citizenship, and salary.

The EmployeeData should create 2 instances of the class Employee and invokes the methods for each object to assign the values for each variable. [Micheal, 23, USA, 30000; Mohammed, 22, Oman, 310000]

Complete the code below for the assignment

import java.io.*;

public class Employee {

String name;

int age;

String citizenship;

double salary;

// This is the constructor of the class Employee

public Employee(String name) {

this.name = name;

}

// Assign the age of the Employee to the variable age.

public void empAge ( . )

{

}

/* Assign the citizenship to the variable citizenship.*/

public void empCitizenship()

{ ..;

}

/* Assign the salary to the variable salary.*/

public void empSalary(..)

{ ;

}

/* Print the Employee details */

public void printEmployee() {

System.out.println("Name:"+ name );

System.out.println("Age:" + age );

System.out.println("Citizenship:" + citizenship );

System.out.println("Salary:" + salary);

}

}

import java.io.*;

public class EmployeeTest {

public static void main(String args[]) {

/* Create two objects using constructor */

Employee empOne =

Employee empTwo = .

// Invoking methods for each object created

..

empOne.printEmployee();

..

..

empTwo.printEmployee();

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions