In this java program, please explain everyline of this code. Thank youuuuuuuuuuu
In this java program, please explain everyline of this code. Thank youuuuuuuuuuu
Source Code:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String name;
String department;
double baseSalary;
String joinedDate;
System.out.print("Enter the Name : ");
name = scanner.nextLine();
System.out.print("Enter the Department : ");
department = scanner.nextLine();
System.out.print("Enter the Joined Date : ");
joinedDate = scanner.nextLine();
System.out.print("Enter the Base Salary : ");
baseSalary = scanner.nextDouble();
StaffDeatils staff = new StaffDeatils(name, department, baseSalary, joinedDate);
System.out.println();
staff.toString();
}
}
class StaffDeatils {
private String name;
private String department;
private double baseSalary;
private String joinedDate;
public StaffDeatils(String name, String department, Double salary, String joinedDate) {
this.name = name;
this.department = department;
this.baseSalary = salary;
this.joinedDate = joinedDate;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public double getBaseSalary() {
return baseSalary;
}
public void setBaseSalary(double baseSalary) {
this.baseSalary = baseSalary;
}
public String toString() {
System.out.println("Donctor Name : " + name);
System.out.println("Department : " + department);
System.out.println("Base Salary : " + baseSalary);
System.out.println("Joined Date : " + joinedDate);
return "";
}
}
Thank you!
Step by step
Solved in 2 steps