To create a Java program to print the below table.
Write a program that would print the information (name, year of joining, salary, address) of
three employees by creating a class named 'Employee'. The output should be as follows:
Name Year of joining Address
Robert 1994 64C- WallsStreat
Sam 2000 68D- WallsStreat
John 1999 26B- WallsStreat
- Define a class named 'Employee' with the following attributes: 'name', 'year_of_joining', 'salary', and 'address'.
- Inside the class, initialise the attributes with the provided values.
- Create three instances of the 'Employee' class, each representing an employee with their respective information.
- Store these instances in variables, providing the necessary values for each attribute.
- Print the header line with the column names: 'Name', 'Year of joining', and 'Address'.
- Print the information of each employee by accessing the attributes.
- Run the program and observe the output displaying the information of the three employees in a tabular format.
import java.util.Scanner;
class Employee
{
String Name;
int Year;
String Address;
Employee(String nam,int years, String addr)
{
Name=nam;
Year=years;
Address=addr;}
void Sam()
{
System.out.println(Name+ " " +Year + " " +Address); }
void Robert()
{
System.out.println(Name+ " " +Year + " " +Address);}
void John()
{
System.out.println(Name+ " "+Year + " " +Address);
}
}
class Main
{
public static void main(String args[])
{
System.out.println("Name " + "Year of Joining " + " Address" );
Employee e=new Employee("Sam ", 2000, " 68D-WallsStreet");
e.Sam();
Employee e1=new Employee("Robert ", 1994, " 64C-WallsStreet");
e1.Robert();
Employee e2=new Employee("John ", 2002, " 70F-WallsStreet");
e2.Sam();
}
}
![image](https://private-user-images.githubusercontent.com/93427376/241610200-8d75e0a8-0746-46ff-8d0c-f239d95dae17.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxNjI4MzMsIm5iZiI6MTcyMjE2MjUzMywicGF0aCI6Ii85MzQyNzM3Ni8yNDE2MTAyMDAtOGQ3NWUwYTgtMDc0Ni00NmZmLThkMGMtZjIzOWQ5NWRhZTE3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI4VDEwMjg1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxYzM1ZjY1N2U1N2NkYWQ0MmYwMjE4OGEwNThlYzIxZTM2OWIyMmM4MGJlMzRmNjY0YmVhMzgwODEyZTU0NDgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.iX2eEs9WM9cQwQyfGI-TWuQbYh6C_1DiQxJ9K0xVUEA)
Thus the desired output is created using Java programming.